Samba 3.0.1 patch for GNU coreutils with _POSIX2_VERSION=200112

Paul Eggert eggert at twinsun.com
Mon Dec 22 23:37:31 GMT 2003


If you set _POSIX2_VERSION=200112 in your environment, GNU coreutils
conforms to the new POSIX version (1003.1-2001) rather than the older
one, and among other things this disables support for the obsolete
command forms "head -1" and "tail -1".  You're supposed to use "head
-n 1" and "tail -n 1" instead.  Unfortunately these new forms are not
supported on some older hosts; it's more portable to use "sed 1q" and
"sed -n '$p'" instead, as these work on all Unix and Unix-like hosts.

Here's a patch relative to Samba 3.0.1 for this problem.

This patch supersedes the message that I submitted in 2002 on this
topic for Samba 2.2.3a, which for some reason got duplicated in the
samba-patches database, at:
<http://samba.org/cgi-bin/samba-patches/incoming?id=657> and
<http://samba.org/cgi-bin/samba-patches/incoming?id=679>.  I realize
that some of this patch affects output documentation files, but I
don't know where the true source files for these doc files are
(if you tell me how to get them, I'll submit patches for them instead).

===================================================================
RCS file: examples/LDAP/ldapsync.pl,v
retrieving revision 3.0.1.0
retrieving revision 3.0.1.1
diff -pu -r3.0.1.0 -r3.0.1.1
--- examples/LDAP/ldapsync.pl	2003/08/28 21:42:41	3.0.1.0
+++ examples/LDAP/ldapsync.pl	2003/12/22 21:49:30	3.0.1.1
@@ -55,7 +55,7 @@ if (!defined($oldpass)) {
 	$ntpassword = substr($ntpwd, index($ntpwd, ':')+1); chomp $ntpassword;
 
 	# Find dn for user $user (maybe check unix password too?)
-	$dn=`ldapsearch -b '$basedn' -s '$scope' '(&(uid=$user)(lmpassword=$lmpassword)(ntpassword=$ntpassword))'|head -1`;
+	$dn=`ldapsearch -b '$basedn' -s '$scope' '(&(uid=$user)(lmpassword=$lmpassword)(ntpassword=$ntpassword))'|sed 1q`;
 	chomp $dn;
 
 	if ($dn eq '') {
@@ -64,7 +64,7 @@ if (!defined($oldpass)) {
 	}
 } else {
 	# Find dn for user $user
-	$dn=`ldapsearch -b '$basedn' -s '$scope' '(uid=$user)'|head -1`;
+	$dn=`ldapsearch -b '$basedn' -s '$scope' '(uid=$user)'|sed 1q`;
 	chomp $dn;
 }
 
===================================================================
RCS file: docs/htmldocs/smb.conf.5.html,v
retrieving revision 3.0.1.0
retrieving revision 3.0.1.1
diff -pu -r3.0.1.0 -r3.0.1.1
--- docs/htmldocs/smb.conf.5.html	2003/12/15 03:47:58	3.0.1.0
+++ docs/htmldocs/smb.conf.5.html	2003/12/22 21:46:53	3.0.1.1
@@ -769,10 +769,10 @@ alias|alias|alias|alias...    
 	determining the disk capacity and remaining space will be used.
 	</em></span></p><p>Example: <b class="command">dfree command = /usr/local/samba/bin/dfree</b></p><p>Where the script dfree (which must be made executable) could be:</p><pre class="programlisting"> 
 #!/bin/sh
-df $1 | tail -1 | awk '{print $2" "$4}'
+df $1 | sed -n '$p' | awk '{print $2" "$4}'
 </pre><p>or perhaps (on Sys V based systems):</p><pre class="programlisting"> 
 #!/bin/sh
-/usr/bin/df -k $1 | tail -1 | awk '{print $3" "$5}'
+/usr/bin/df -k $1 | sed -n '$p' | awk '{print $3" "$5}'
 </pre><p>Note that you may have to replace the command names with full path names on some systems.</p></dd><dt><span class="term"><a name="DIRECTORY"></a>directory (S)</span></dt><dd><p>Synonym for <a href="#PATH"><i class="parameter"><tt>path</tt></i></a>.</p></dd><dt><span class="term"><a name="DIRECTORYMASK"></a>directory mask (S)</span></dt><dd><p>This parameter is the octal modes which are 
     used when converting DOS modes to UNIX modes when creating UNIX 
     directories.</p><p>When a directory is created, the necessary permissions are 
===================================================================
RCS file: docs/htmldocs/using_samba/ch11.html,v
retrieving revision 3.0.1.0
retrieving revision 3.0.1.1
diff -pu -r3.0.1.0 -r3.0.1.1
--- docs/htmldocs/using_samba/ch11.html	2003/08/19 20:29:52	3.0.1.0
+++ docs/htmldocs/using_samba/ch11.html	2003/12/22 21:46:09	3.0.1.1
@@ -1706,12 +1706,12 @@ space in a block and the number of avail
 documentation recommends the following as a usable script:</p>
 
 <blockquote><pre class="code">#!/bin/sh
-df $1 | tail -1 | awk '{print $2&quot; &quot;$4}'</pre></blockquote>
+df $1 | sed -n '$p' | awk '{print $2&quot; &quot;$4}'</pre></blockquote>
 
 <p>On System V machines, the following will work:</p>
 
 <blockquote><pre class="code">#!/bin/sh
-/usr/bin/df $1 | tail -1 | awk '{print $3&quot; &quot;$5}'</pre></blockquote>
+/usr/bin/df $1 | sed -n '$p' | awk '{print $3&quot; &quot;$5}'</pre></blockquote>
 
 
 </div>
===================================================================
RCS file: docs/manpages/smb.conf.5,v
retrieving revision 3.0.1.0
retrieving revision 3.0.1.1
diff -pu -r3.0.1.0 -r3.0.1.1
--- docs/manpages/smb.conf.5	2003/12/15 03:46:34	3.0.1.0
+++ docs/manpages/smb.conf.5	2003/12/22 21:56:57	3.0.1.1
@@ -2619,7 +2619,7 @@ Where the script dfree (which must be ma
 .nf
  
 #!/bin/sh
-df $1 | tail \-1 | awk '{print $2" "$4}'
+df $1 | sed \-n '$p' | awk '{print $2" "$4}'
 .fi
 
 
@@ -2629,7 +2629,7 @@ or perhaps (on Sys V based systems):
 .nf
  
 #!/bin/sh
-/usr/bin/df \-k $1 | tail \-1 | awk '{print $3" "$5}'
+/usr/bin/df \-k $1 | sed \-n '$p' | awk '{print $3" "$5}'
 .fi
 
 


More information about the samba-technical mailing list