LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-22-2019, 04:42 PM   #1
GazL
LQ Guru
 
Registered: May 2008
Posts: 5,298
Blog Entries: 18

Rep: Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063
makepkg link handling weakness/bug


I was just trying to package my libressl build and I've stumbled onto a problem with pkgtools link handling. When I did an installpkg it threw out a handful of bash errors about 'type' file not found.

I tracked it down to these man-page symlinks:
Code:
# ls -l | grep '<type>'
lrwxrwxrwx 1 build build     8 Nov 22 21:00 lh_<type>_delete.3 -> lh_new.3
lrwxrwxrwx 1 build build     8 Nov 22 21:00 lh_<type>_doall.3 -> lh_new.3
lrwxrwxrwx 1 build build     8 Nov 22 21:00 lh_<type>_doall_arg.3 -> lh_new.3
lrwxrwxrwx 1 build build     8 Nov 22 21:00 lh_<type>_error.3 -> lh_new.3
lrwxrwxrwx 1 build build     8 Nov 22 21:00 lh_<type>_free.3 -> lh_new.3
lrwxrwxrwx 1 build build     8 Nov 22 21:00 lh_<type>_insert.3 -> lh_new.3
lrwxrwxrwx 1 build build     8 Nov 22 21:00 lh_<type>_new.3 -> lh_new.3
lrwxrwxrwx 1 build build     8 Nov 22 21:00 lh_<type>_retrieve.3 -> lh_new.3
#
The problem is that makepkg converts them into entries of the following format in doinst.sh
Code:
( cd opt/libressl-3.0.2/man/man3 ; rm -rf lh_<type>_delete.3.gz )
which without any sort of quoting/escaping results in an obvious error.

Anyway, I worked around it by using makepkg '-l n', but I thought I'd mention it, especially as the first you know about it is when you install the package.
 
Old 11-23-2019, 04:52 AM   #2
GazL
LQ Guru
 
Registered: May 2008
Posts: 5,298

Original Poster
Blog Entries: 18

Rep: Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063
FIX:
Code:
--- makepkg.orig        2019-11-23 09:42:26.974838824 +0000
+++ makepkg     2019-11-23 09:41:35.701190106 +0000
@@ -298,7 +298,7 @@
 echo "Searching for symbolic links:"
 # Get rid of possible pre-existing trouble:
 INST=$(mktemp $TMP/makepkg.XXXXXX)
-find . -type l -printf "%p\t%l\n" | LC_COLLATE=C sort | sed 's,^\./,, ; s, ,\\ ,g' | tee $INST
+find . -type l -printf "%p\t%l\n" | LC_COLLATE=C sort | sed 's,^\./,, ; s,\([<> ]\),\\\1,g' | tee $INST
 if [ ! "$(cat $INST)" = "" ]; then
   echo
   echo "Making symbolic link creation script:"
you might want to consider adding the other shell special characters to the set of characters to be escaped, but I'll leave that with you.

Last edited by GazL; 11-23-2019 at 04:58 AM.
 
Old 11-23-2019, 03:38 PM   #3
Xsane
Member
 
Registered: Jan 2014
Posts: 152

Rep: Reputation: 112Reputation: 112
Quote:
Originally Posted by GazL View Post
FIX:
Code:
--- makepkg.orig        2019-11-23 09:42:26.974838824 +0000
+++ makepkg     2019-11-23 09:41:35.701190106 +0000
@@ -298,7 +298,7 @@
 echo "Searching for symbolic links:"
 # Get rid of possible pre-existing trouble:
 INST=$(mktemp $TMP/makepkg.XXXXXX)
-find . -type l -printf "%p\t%l\n" | LC_COLLATE=C sort | sed 's,^\./,, ; s, ,\\ ,g' | tee $INST
+find . -type l -printf "%p\t%l\n" | LC_COLLATE=C sort | sed 's,^\./,, ; s,\([<> ]\),\\\1,g' | tee $INST
 if [ ! "$(cat $INST)" = "" ]; then
   echo
   echo "Making symbolic link creation script:"
you might want to consider adding the other shell special characters to the set of characters to be escaped, but I'll leave that with you.
Won't that facilitate the creation of links with non-POSIX
file names?

Shouldn't the build system be replacing <type> with
something? An upstream bug perhaps?
 
Old 11-23-2019, 03:45 PM   #4
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 1,793

Rep: Reputation: 5753Reputation: 5753Reputation: 5753Reputation: 5753Reputation: 5753Reputation: 5753Reputation: 5753Reputation: 5753Reputation: 5753Reputation: 5753Reputation: 5753
Quote:
Originally Posted by Xsane View Post
Won't that facilitate the creation of links with non-POSIX
file names?
Yes, but that seems better than tripping over those filenames.

Quote:
Shouldn't the build system be replacing <type> with
something? An upstream bug perhaps?
I suspect that is the case since these man page names can't even be looked up with "man" without some manual escaping on the command line.
 
Old 11-23-2019, 04:05 PM   #5
GazL
LQ Guru
 
Registered: May 2008
Posts: 5,298

Original Poster
Blog Entries: 18

Rep: Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063
Well, it's outside the POSIX fully portable filenames standard, but that's fairly limited and most hi ascii and unicode characters would also fall outside of that.

I'm assuming the '<type>' is referring to something akin to a C++ function template.
Here's a snipet of one of the manpages:
Quote:
SYNOPSIS
#include <openssl/lhash.h>

DECLARE_LHASH_OF(<type>);

LHASH *
lh_<type>_new(void);

void
lh_<type>_free(LHASH_OF(<type>) *table);

<type> *
lh_<type>_insert(LHASH_OF(<type>) *table, <type> *data);
 
1 members found this post helpful.
Old 11-24-2019, 09:54 AM   #6
NonNonBa
Member
 
Registered: Aug 2010
Distribution: Slackware
Posts: 108

Rep: Reputation: Disabled
Hello,

Quote:
Originally Posted by volkerdi View Post
Yes, but that seems better than tripping over those filenames.
I think there are some shell-meaningful chars missing in the current makepkg (plus "\&" in the RE is certainly meant to be "\\&": here you want to escape the escape don't you? ). I'd suggest:

Code:
find . -type l -printf "%p\t%l\n" | LC_COLLATE=C sort | sed 's,^\./,,; s,[ "#$&\x27()*;<>?[\\`{|~],\\&,g;' | tee $INST
We even could handle TAB, but it would then require to change some bits in make_install_script(). I can submit a patch, if you nevertheless think it worth the change.

Will then however remain the NL issue, but escaping it wouldn't help much as the i/o are read line per line in the pkgtools...

Last edited by NonNonBa; 11-24-2019 at 01:35 PM. Reason: typo
 
3 members found this post helpful.
Old 11-24-2019, 11:11 AM   #7
GazL
LQ Guru
 
Registered: May 2008
Posts: 5,298

Original Poster
Blog Entries: 18

Rep: Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063Reputation: 3063
yes, nice improvement. I should have thought of using '&' instead of the sub-expression back-reference in the first place.

It's a shame this script is sh rather than bash, otherwise printf "%q" could have been leveraged.
 
Old 11-24-2019, 01:35 PM   #8
NonNonBa
Member
 
Registered: Aug 2010
Distribution: Slackware
Posts: 108

Rep: Reputation: Disabled
Quote:
Originally Posted by GazL View Post
It's a shame this script is sh rather than bash, otherwise printf "%q" could have been leveraged.
Yes, as bash is now in the initrd of the installer, I think all could be /bin/bash shebanged. You can however hardly run Slack without bash, as the network config relies on arrays, which (da)sh won't provide.

Now, the more the complexity of the pkgtools increases, the more I wonder if /usr/bin/perl would not be the suited language. It would save all the locale issues, and provide a stable and powerful "shell-feeling" programming environment to manipulate strings, which is the heart of the these scripts. But of course, it's just a foolish thought of mine.
 
1 members found this post helpful.
Old 11-26-2019, 12:22 AM   #9
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 3,529

Rep: Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886
Quote:
Originally Posted by NonNonBa View Post
[...] the more I wonder if /usr/bin/perl would not be the suited language.
Projectile vomits.


Dealing with perl is similar to having the Devil break wind into your face.

IMO; your mileage may vary.
 
Old 11-26-2019, 06:43 AM   #10
NonNonBa
Member
 
Registered: Aug 2010
Distribution: Slackware
Posts: 108

Rep: Reputation: Disabled
Well, I must admit each time I dive back into it after a while without practising, I have a WTF moment. But after, it's just plain fun with text processing. You are not enforced to use OOP, making you just feel at home if you are a bit used to AWK and sed, and a thing like s/(RE)(RE)(RE)/some_function($2,$1,$3)/seg is one of the coolest I have ever seen.

Plus, the language is stable regarding the old code. For example I never liked Frozen Bubble 2.X, prefering the design of the 1.X and having no care for its new network support. While it is a big application for which you certainly would never think of Perl and it have been leaving unmaintained for >15years, I spent no more than one big hour for the whole (search the doc, fix the code, patch and repack) to keep it running.

But don't get me wrong, though. Here I don't advocate Perl is the best language you have ever met, just it's IMO the best alternative when you love shell programing (which is also subject to much loathing, BTW) as I do.

Last edited by NonNonBa; 11-26-2019 at 06:44 AM.
 
1 members found this post helpful.
Old 11-28-2019, 02:11 AM   #11
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 3,529

Rep: Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886
Quote:
Originally Posted by NonNonBa View Post
Well, I must admit each time I dive back into it after a while without practising, I have a WTF moment. But after, it's just plain fun with text processing. You are not enforced to use OOP, making you just feel at home if you are a bit used to AWK and sed, and a thing like s/(RE)(RE)(RE)/some_function($2,$1,$3)/seg is one of the coolest I have ever seen.

Plus, the language is stable regarding the old code. For example I never liked Frozen Bubble 2.X, prefering the design of the 1.X and having no care for its new network support. While it is a big application for which you certainly would never think of Perl and it have been leaving unmaintained for >15years, I spent no more than one big hour for the whole (search the doc, fix the code, patch and repack) to keep it running.

But don't get me wrong, though. Here I don't advocate Perl is the best language you have ever met, just it's IMO the best alternative when you love shell programing (which is also subject to much loathing, BTW) as I do.
TLDR: I'll admit that my reaction was a bit over the top. Long and boring rant follows.

I've had to support various flavors of perl scripts in the Day Job over the years. Some of them were written by software engineers who tried very very hard to make said scripts comprehensible by the poor support weasel(s) who would have to, well, support them.

The problem with perl from my perspective is that it is a very rich scripting language. You can find a subset of perl that perfectly matches the way you personally think and write code. (Kinda like FORTH in a way.) It's almost like you can create a language of your own in perl.

Some of us (me, for example), absolutely suck at learning new human languages with their who-fucking-dreamed-THAT-up rules. (And my native tongue is American English which is chock full of who-fucking-dreamed-THAT-up rules!)

I've found that reading someone else's perl code is a close parallel to learning a new human language with who-fucking-dreamed-THAT-up rules. It's perfectly clear to the person who wrote it and it's perfectly clear to someone who understands the dialect of that subset of perl. I'm not one of them.

I give full and unbounded props to the perl documentation! I may hate the language, but there's no lack of default help available for every function, wart, and weird construct perl uses. (That may seem to be a back-handed complement, but I really mean it. I can't think of much more a human could do to effectively document perl. If you have a question, the answer is almost certainly there.)

I'm more of a python fan, where the concept is "there's pretty much one way to do it". That isn't really true in python, although the language steers you in a particular direction for most things. I've been able to read years old python code and see what is going on; I've read perl code the day after I've written it and have had to hit the man pages to figure out what the Hell I had done.

Your mileage may vary and probably will. Don't ask me about Ruby.
 
1 members found this post helpful.
Old 11-30-2019, 05:11 AM   #12
NonNonBa
Member
 
Registered: Aug 2010
Distribution: Slackware
Posts: 108

Rep: Reputation: Disabled
Quote:
Originally Posted by Richard Cranium View Post
TLDR: I'll admit that my reaction was a bit over the top. Long and boring rant follows. [...]
I agree, the expressiveness of Perl is both its force and its weakness. Maybe not to the extent of a human language though, because even the most obfuscated expression is still logic at the end, while a human language is both logic and music (for example I always admire the foreigners succeeding in dealing with French conjugacy, because the only criteria I personally know to place a verb in its group is "it sounds good/weird"). Still, it seems fair to say the longest the code is, the more your Perl is subject to turn "dialectal". So all the (less than hypothetical) question would be: in how much Perl code a pkgtools re-implementation would be held?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bug in makepkg and symlinks with blanks in filename? DarkVision Slackware 52 10-01-2015 11:57 PM
LXer: Safend Finds Weakness in Linux Random Number Generator LXer Syndicated Linux News 0 05-01-2006 03:54 PM
https for ecommerce + biggest weakness ? darkRoom Linux - Security 4 03-09-2006 06:31 AM
Fatal weakness in Linux cov Linux - Software 71 07-05-2005 05:13 AM
What would you say is the most basic Linux weakness wayloud Linux - Security 3 12-09-2003 05:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration