All of lore.kernel.org
 help / color / mirror / Atom feed
* [SETSEBOOL] Miscellaneous cleanups
@ 2005-12-23 23:29 Ivan Gyurdiev
  0 siblings, 0 replies; only message in thread
From: Ivan Gyurdiev @ 2005-12-23 23:29 UTC (permalink / raw)
  To: selinux; +Cc: Stephen Smalley

[-- 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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-12-23 23:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-23 23:29 [SETSEBOOL] Miscellaneous cleanups Ivan Gyurdiev

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.