Skip to contentSkip to conversation

Add version option to newrole

PATCH In review Glauber de Oliveira Costa 3 participants 7 messages Feb 8, 2006 – Feb 10, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add version option to newrole

Here's a new version that incorporates your suggestions. I moved the constant definition to the makefile, and also, I'm gathering the data from the version file. Also, Steve, I would like to hear from you why do you think the -v option is not that descriptive.

If you guys accept this patch, my obvious next step would be adding it to the manpage.

Glauber.

newrole/Makefile +2 -1
diff -upNr policycoreutils-1.29.18/newrole/Makefile policycoreutils-1.29.18.mine/newrole/Makefile
@@ -10,9 +10,10 @@ AUDITH = $(shell ls /usr/include/libaudi
 # This is so that we have the CAP_AUDIT_WRITE capability. newrole will
 # shed all privileges and change to the user's uid.
 LOG_AUDIT_PRIV ?= n
+VERSION = $(shell cat ../VERSION)
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += $(LDFLAGS) -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
+override CFLAGS += -DVERSION=\"$(VERSION)\" $(LDFLAGS) -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
 LDLIBS += -lselinux -lsepol -L$(PREFIX)/lib
 ifeq (${PAMH}, /usr/include/security/pam_appl.h)
 	override CFLAGS += -DUSE_PAM

Binary files policycoreutils-1.29.18/newrole/newrole and policycoreutils-1.29.18.mine/newrole/newrole differ

newrole/newrole.c +8 -3
diff -upNr policycoreutils-1.29.18/newrole/newrole.c policycoreutils-1.29.18.mine/newrole/newrole.c
@@ -10,7 +10,7 @@
  *
  * USAGE:
  *
- * newrole [ -r role ] [ -t type ] [ -l level ] [ -- args ]
+ * newrole [ -r role ] [ -t type ] [ -l level ] [ -v ] [ -- args ]
  *
  * BUILD OPTIONS:
  *
@@ -84,7 +84,7 @@
 #endif
 
 /* USAGE_STRING describes the command-line args of this program. */
-#define USAGE_STRING "USAGE: newrole [ -r role ] [ -t type ] [ -l level ] [ -- args ]"
+#define USAGE_STRING "USAGE: newrole [ -r role ] [ -t type ] [ -l level ] [ -v ] [ -- args ]"
 
 #define DEFAULT_CONTEXT_SIZE 255  /* first guess at context size */
 
@@ -417,6 +417,7 @@ int main( int argc, char *argv[] ) {
     { "role", 1, 0, 'r' },
     { "type", 1, 0, 't' },
     { "level", 1, 0, 'l' },
+    { "version", 0, 0, 'v' },
     { NULL, 0, 0, 0 }
   };
   char *role_s = NULL;               /* role spec'd by user in argv[] */
@@ -465,11 +466,15 @@ int main( int argc, char *argv[] ) {
   }
 
   while (1) {
-    clflag=getopt_long(argc,argv,"r:t:l:",long_options,&flag_index);
+    clflag=getopt_long(argc,argv,"r:t:l:v",long_options,&flag_index);
     if (clflag == -1)
 	break;
     
     switch( clflag ) {
+    case 'v':
+	printf("newrole version %s\n",VERSION);
+	exit(0);
+	break;
     case 'r':
       /* If role_s is already set, the user spec'd multiple roles - bad. */
       if( role_s ) {
#1 lore raw
Quoted 7 lines · Glauber de Oliveira Costa

Here's a new version that incorporates your suggestions. I moved the constant definition to the makefile, and also, I'm gathering the data from the version file. Also, Steve, I would like to hear from you why do you think the -v option is not that descriptive.

If you guys accept this patch, my obvious next step would be adding it to the manpage.

I think his complaint was with our existing usage message (the args part), not your change.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
In reply to Glauber de Oliveira Costa
Quoted 2 lines

I moved the constant definition to the makefile, and also, I'm gathering the

data

Quoted 1 line

from the version file.

Thanks. That should be easier to maintain.

Quoted 2 lines

Also, Steve, I would like to hear from you why do you think the -v option is not that descriptive.

OK my bad. I though the -- ARGS was added. -v is fine.

But waht about the other programs? load_policy, restorecon, run_init, etc...

-Steve

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw

Em Quarta 08 Fevereiro 2006 15:10, Steve G escreveu:

Quoted 8 lines
Quoted 2 lines

I moved the constant definition to the makefile, and also, I'm gathering the

data

Quoted 1 line

from the version file.

Thanks. That should be easier to maintain.

Np.

Quoted 7 lines
Quoted 2 lines

Also, Steve, I would like to hear from you why do you think the -v option is not that descriptive.

OK my bad. I though the -- ARGS was added. -v is fine.

But waht about the other programs? load_policy, restorecon, run_init, etc...

Note that it would be too much spent work *IF* you don't like the idea. So, here is newrole implementation for your appreciation. If you guys tell me "Ok, version option is good, we'll merge it", I'll then implement it in other programs, and document it in their respective manpages.

Also, if there are any of the policycoreutils programs that for any reason should *not* have a version option for any reason, please let me know the program along with the reasons, and I'll skip it.

Quoted 1 line

-Steve

Glauber.

Quoted 4 lines

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
In reply to Glauber de Oliveira Costa
Quoted 7 lines · Glauber de Oliveira Costa

Here's a new version that incorporates your suggestions. I moved the constant definition to the makefile, and also, I'm gathering the data from the version file. Also, Steve, I would like to hear from you why do you think the -v option is not that descriptive.

If you guys accept this patch, my obvious next step would be adding it to the manpage.

At present, your patch causes newrole to display the version number of the entire collection (policycoreutils), not an individual version tied to the newrole program itself. Thus, I think it should display the PACKAGE string as well (already defined) as part of the message, e.g.:

	printf("%s:  %s version %s\n", argv[0], PACKAGE, VERSION);

yielding output like:
newrole: policycoreutils version 1.29.20

Otherwise, the patch seems sane and suitable for the other utilities as well. A few of the utilities appear to have their own version string at present, but I think you can just drop that as no one is maintaining that - only the top-level VERSION for the entire collection is meaningful.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#5 lore raw
Quoted 5 lines · Stephen Smalley

At present, your patch causes newrole to display the version number of the entire collection (policycoreutils), not an individual version tied to the newrole program itself. Thus, I think it should display the PACKAGE string as well (already defined) as part of the message, e.g.:

	printf("%s:  %s version %s\n", argv[0], PACKAGE, VERSION);
Quoted 8 lines

yielding output like:
newrole: policycoreutils version 1.29.20

Otherwise, the patch seems sane and suitable for the other utilities as well. A few of the utilities appear to have their own version string at present, but I think you can just drop that as no one is maintaining that - only the top-level VERSION for the entire collection is meaningful.

Also, using -v is ambiguous, as it often means to run a program under a verbose mode (extra output), and several utilities are using -v in that way, so use -V and/or --version instead.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw

Em Quinta 09 Fevereiro 2006 18:12, Stephen Smalley escreveu:

Quoted 8 lines · Stephen Smalley
Quoted 7 lines

At present, your patch causes newrole to display the version number of the entire collection (policycoreutils), not an individual version tied to the newrole program itself. Thus, I think it should display the PACKAGE string as well (already defined) as part of the message, e.g.:

	printf("%s:  %s version %s\n", argv[0], PACKAGE, VERSION);

yielding output like:
newrole: policycoreutils version 1.29.20

argv[0] will display the complete path of the command being called. I think this is not what we want.

Quoted 9 lines
Quoted 5 lines

Otherwise, the patch seems sane and suitable for the other utilities as well. A few of the utilities appear to have their own version string at present, but I think you can just drop that as no one is maintaining that - only the top-level VERSION for the entire collection is meaningful.

Also, using -v is ambiguous, as it often means to run a program under a verbose mode (extra output), and several utilities are using -v in that way, so use -V and/or --version instead.

Sure this is confusing. A lot of programs use -v for version (see GNU Binutils), some don't use a shortopt at all (see GNU coreutils), and some use the suggested -V (see GNU zip). I'll cope with your suggestion and use -V

I'll send a new version of newrole's implementation together with the manpage patch soon, and patches for the other programs as soon as I can too.

glauber.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.