To: | source-reviewers@MIT.EDU |
Subject: | tail portability bug in k5srvutil |
Date: | Sat, 24 Feb 2007 18:12:40 -0500 |
From: | Robert A Basch <rbasch@MIT.EDU> |
Cc: | krb5-bugs@MIT.EDU |
"k5srvutil change" failed on a RHEL-5 beta machine, where the tail
command, in an apparent effort to be more POSIX compliant, no longer
recognizes the "+<number>" option. This patch fixes the problem by
making use of awk's NR variable, thereby obviating the use of tail.
(Note that the POSIX tail's "-n" option is not portable, and in
particular is not accepted on Solaris),
Index: k5srvutil.sh
===================================================================
RCS file: /afs/dev.mit.edu/source/repository/third/krb5/src/kadmin/cli/k5srvutil.sh,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 k5srvutil.sh
--- k5srvutil.sh 27 Feb 2004 04:01:52 -0000 1.1.1.1
+++ k5srvutil.sh 24 Feb 2007 21:41:47 -0000
@@ -4,7 +4,7 @@
# returns a list of principals in the keytab
# sorted and uniquified
list_princs() {
- klist -k $keytab | tail +4 | awk '{print $2}' | sort | uniq
+ klist -k $keytab | awk '(NR > 3) {print $2}' | sort | uniq
}
set_command() {
command, in an apparent effort to be more POSIX compliant, no longer
recognizes the "+<number>" option. This patch fixes the problem by
making use of awk's NR variable, thereby obviating the use of tail.
(Note that the POSIX tail's "-n" option is not portable, and in
particular is not accepted on Solaris),
Index: k5srvutil.sh
===================================================================
RCS file: /afs/dev.mit.edu/source/repository/third/krb5/src/kadmin/cli/k5srvutil.sh,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 k5srvutil.sh
--- k5srvutil.sh 27 Feb 2004 04:01:52 -0000 1.1.1.1
+++ k5srvutil.sh 24 Feb 2007 21:41:47 -0000
@@ -4,7 +4,7 @@
# returns a list of principals in the keytab
# sorted and uniquified
list_princs() {
- klist -k $keytab | tail +4 | awk '{print $2}' | sort | uniq
+ klist -k $keytab | awk '(NR > 3) {print $2}' | sort | uniq
}
set_command() {