RE: [PATCH 14/15] [src-policy] semodule: user message support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2010-02-01 at 12:00 -0500, Caleb Case wrote:
> 
> > -----Original Message-----
> > From: James Carter [mailto:jwcart2@xxxxxxxxxxxxx]
> > Sent: Monday, February 01, 2010 10:12 AM
> > To: Caleb Case
> > Cc: selinux@xxxxxxxxxxxxx; Chad Sellers; Karl MacMillan; Joshua
> Brindle;
> > sds@xxxxxxxxxxxxx
> > Subject: Re: [PATCH 14/15] [src-policy] semodule: user message support
> > 
> > On Tue, 2010-01-26 at 17:08 -0500, Caleb Case wrote:
> > > This adds the -m,--message option to semodule so that users can
> specify
> > > a message for the ChangeLog.
> > >
> > 
> > Is there plans to add user message support to semanage?
> Unfortunately,
> > in semanage "-m" is already in use.
> 
> Yes, maybe -M is better so we can use the same flag in both tools?

It would be confusing to have different flags, so -M is better.  It
would have been nice to use -m since cvs, svn, and git all use it for
log messages.  Oh well.

> 
> > 
> > >   -m,--message=MSG user message for the ChangeLog
> > >
> > > Example:
> > >
> > > # semodule -E alsa -m "Allow alsa to execute cowsay."
> > > ---
> > >  policycoreutils/semodule/semodule.8 |    3 +++
> > >  policycoreutils/semodule/semodule.c |   24 +++++++++++++++++++++++-
> > >  2 files changed, 26 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/policycoreutils/semodule/semodule.8
> > b/policycoreutils/semodule/semodule.8
> > > index 8baad8b..97d31dd 100644
> > > --- a/policycoreutils/semodule/semodule.8
> > > +++ b/policycoreutils/semodule/semodule.8
> > > @@ -87,6 +87,9 @@ prints help message and quit
> > >  .TP
> > >  .B  \-v,\-\-verbose
> > >  be verbose
> > > +.TP
> > > +.B  \-m,\-\-message=MSG
> > > +user message for the ChangeLog
> > >
> > >  .SH EXAMPLE
> > >  .nf
> > > diff --git a/policycoreutils/semodule/semodule.c
> > b/policycoreutils/semodule/semodule.c
> > > index 3536253..c8bf986 100644
> > > --- a/policycoreutils/semodule/semodule.c
> > > +++ b/policycoreutils/semodule/semodule.c
> > > @@ -58,6 +58,7 @@ static int create_store;
> > >  static int build;
> > >  static int disable_dontaudit;
> > >  static uint16_t priority;
> > > +static char *message = NULL;
> > >
> > >  static semanage_handle_t *sh = NULL;
> > >  static char *store;
> > > @@ -72,6 +73,8 @@ static void cleanup(void)
> > >  		free(commands[num_commands].output);
> > >  	}
> > >  	free(commands);
> > > +
> > > +	free(message);
> > >  }
> > >
> > >  /* Signal handlers. */
> > > @@ -134,6 +137,7 @@ static void usage(char *progname)
> > >  	printf("  -h,--help        print this message and quit\n");
> > >  	printf("  -v,--verbose     be verbose\n");
> > >  	printf("  -D,--disable_dontaudit	Remove dontaudits from
> > policy\n");
> > > +	printf("  -m,--message=MSG user message for the ChangeLog\n");
> > >  }
> > >
> > >  /* Sets the global mode variable to new_mode, but only if no other
> > > @@ -186,6 +190,7 @@ static void parse_command_line(int argc, char
> > **argv)
> > >  		{"output", required_argument, NULL, 'o'},
> > >  		{"cil", 0, NULL, 'c'},
> > >  		{"edit", required_argument, NULL, 'E'},
> > > +		{"message", required_argument, NULL, 'm'},
> > >  		{NULL, 0, NULL, 0}
> > >  	};
> > >  	int i;
> > > @@ -195,7 +200,7 @@ static void parse_command_line(int argc, char
> > **argv)
> > >  	create_store = 0;
> > >  	priority = 400;
> > >  	while ((i =
> > > -		getopt_long(argc, argv,
> "s:b:hi:l::vqr:u:RnBDp:e:d:g:o:cE:",
> > opts,
> > > +		getopt_long(argc, argv,
> "s:b:hi:l::vqr:u:RnBDp:e:d:g:o:cE:m:",
> > opts,
> > >  			    NULL)) != -1) {
> > >  		switch (i) {
> > >  		case 'b':
> > > @@ -294,6 +299,13 @@ static void parse_command_line(int argc, char
> > **argv)
> > >  		case 'E':
> > >  			set_mode(EDIT_M, optarg);
> > >  			break;
> > > +		case 'm':
> > > +			message = strdup(optarg);
> > > +			if (message == NULL) {
> > > +				fprintf(stderr, "Failed to set message
> (out of
> > memory).");
> > > +				exit(1);
> > > +			}
> > > +			break;
> > >  		case '?':
> > >  		default:{
> > >  				usage(argv[0]);
> > > @@ -414,6 +426,16 @@ int main(int argc, char *argv[])
> > >  		goto cleanup;
> > >  	}
> > >
> > > +	if (message) {
> > > +		result = semanage_set_log_message(sh, message);
> > > +		if (result != 0) {
> > > +			fprintf(stderr,
> > > +				"%s: Failed to set ChangeLog message.",
> > > +				argv[0]);
> > > +			goto cleanup;
> > > +		}
> > > +	}
> > > +
> > >  	for (i = 0; i < num_commands; i++) {
> > >  		enum client_modes mode = commands[i].mode;
> > >  		char *mode_arg = commands[i].arg;
> > 
> > --
> > James Carter <jwcart2@xxxxxxxxxxxxx>
> > National Security Agency
> 
> 
> 
> --
> This message was distributed to subscribers of the selinux mailing list.
> If you no longer wish to subscribe, send mail to majordomo@xxxxxxxxxxxxx with
> the words "unsubscribe selinux" without quotes as the message.

-- 
James Carter <jwcart2@xxxxxxxxxxxxx>
National Security Agency


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

[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux