All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Gyurdiev <ivg2@cornell.edu>
To: selinux@tycho.nsa.gov
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Subject: [SETSEBOOL] Miscellaneous cleanups
Date: Fri, 23 Dec 2005 18:29:03 -0500	[thread overview]
Message-ID: <43AC883F.6000600@cornell.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

Remove unused ret variable causing confusion.
Simplify handling of strdup failure - the only reason strdup will fail 
is OMEM,
in which case there's no reason to go into detail regarding exactly 
which boolean failed.


[-- Attachment #2: setsebool.misc_cleanup.diff --]
[-- Type: text/x-patch, Size: 1900 bytes --]

diff -Naurp --exclude-from excludes old/policycoreutils/setsebool/setsebool.c new/policycoreutils/setsebool/setsebool.c
--- old/policycoreutils/setsebool/setsebool.c	2005-11-09 08:49:41.000000000 -0500
+++ new/policycoreutils/setsebool/setsebool.c	2005-12-23 18:17:08.000000000 -0500
@@ -173,16 +173,14 @@ static int semanage_set_boolean_list(
 int setbool(char **list, size_t start, size_t end)
 {
 	char *name, *value_ptr;
-	int ret=0, j=0, value;
+	int j=0, value;
 	size_t i = start;
 	size_t boolcnt=end-start;
 	struct passwd *pwd;
 	SELboolean *vallist=calloc(boolcnt, sizeof(SELboolean));
-	if (!vallist) {
-		fprintf(stderr, 
-			"Error setting booleans: %s\n", strerror(errno));
-		return 1;
-	}
+	if (!vallist)
+		goto omem;
+
 	while (i < end) {
 		name = list[i];
 		value_ptr = strchr(list[i], '=');
@@ -190,7 +188,6 @@ int setbool(char **list, size_t start, s
 			fprintf(stderr, 
 			"setsebool: '=' not found in boolean expression %s\n",
 				list[i]);
-			ret=4;
 			goto err;
 		}
 		*value_ptr = 0;
@@ -202,21 +199,16 @@ int setbool(char **list, size_t start, s
 				strcasecmp(value_ptr, "false") == 0)
 			value = 0;
 		else {
-			fprintf(stderr, "setsebool: illegal boolean value %s\n",
-				value_ptr);
-			ret=1;
+			fprintf(stderr, "setsebool: illegal value "
+					"%s for boolean %s\n",
+					value_ptr, name);
 			goto err;
 		}
 
 		vallist[j].value = value;
 		vallist[j].name = strdup(name);
-		if (!vallist[j].name) {
-			fprintf(stderr, 
-				"Error setting boolean %s to value %d (%s)\n", 
-				name, value, strerror(errno));
-			ret= 2;
-			goto err;
-		}
+		if (!vallist[j].name)
+			goto omem;
 		i++;
 		j++;
 
@@ -257,7 +249,10 @@ int setbool(char **list, size_t start, s
 		free(vallist[i].name);
 	free(vallist);
 	return 0;
-				
+		
+	omem:
+	fprintf(stderr, "setsebool: out of memory");
+		
 	err:
 	for (i=0; i < boolcnt; i++) 
 		free(vallist[i].name);

                 reply	other threads:[~2005-12-23 23:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43AC883F.6000600@cornell.edu \
    --to=ivg2@cornell.edu \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.