aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-08-06 02:36:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-08-06 02:36:35 +0000
commit84d71f33f5f0201e15bb07d523cef711cd8ef44f (patch)
treecd04f708fa6b6fe508054f72408d9c92f29479bc
parent46340e398e93898ce097b06f5e26c86e33fd651a (diff)
downloadbusybox-w32-84d71f33f5f0201e15bb07d523cef711cd8ef44f.tar.gz
busybox-w32-84d71f33f5f0201e15bb07d523cef711cd8ef44f.tar.bz2
busybox-w32-84d71f33f5f0201e15bb07d523cef711cd8ef44f.zip
setfiles:
* Bug fix: -f option did not work. * Using bb_simplify_path to remove extra slash for smaller code. (by Yuichi Nakamura <ynakam@hitachisoft.jp>)
-rw-r--r--selinux/setfiles.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/selinux/setfiles.c b/selinux/setfiles.c
index 352c0f224..df77d6053 100644
--- a/selinux/setfiles.c
+++ b/selinux/setfiles.c
@@ -264,28 +264,21 @@ static bool only_changed_user(const char *a, const char *b)
264 264
265static int restore(const char *file) 265static int restore(const char *file)
266{ 266{
267 char *my_file = xstrdup(file); 267 char *my_file;
268 char *my_file_orig = my_file;
269 struct stat my_sb; 268 struct stat my_sb;
270 int i, j, ret; 269 int i, j, ret;
271 char *context = NULL; 270 char *context = NULL;
272 char *newcon = NULL; 271 char *newcon = NULL;
273 bool user_only_changed = 0; 272 bool user_only_changed = 0;
274 size_t len = strlen(my_file);
275 int retval = 0; 273 int retval = 0;
276 274
277 /* Skip the extra slashes at the beginning and end, if present. */ 275 my_file = bb_simplify_path(file);
278 if (file[0] == '/' && file[1] == '/')
279 my_file++;
280 if (len > 1 && my_file[len - 1] == '/')
281 my_file[len - 1] = '\0';
282 276
283 i = match(my_file, &my_sb, &newcon); 277 i = match(my_file, &my_sb, &newcon);
284 278
285 if (i < 0) /* No matching specification. */ 279 if (i < 0) /* No matching specification. */
286 goto out; 280 goto out;
287 281
288
289 if (FLAG_p_progress) { 282 if (FLAG_p_progress) {
290 count++; 283 count++;
291 if (count % 0x400 == 0) { /* every 1024 times */ 284 if (count % 0x400 == 0) { /* every 1024 times */
@@ -386,7 +379,7 @@ static int restore(const char *file)
386 out: 379 out:
387 freecon(context); 380 freecon(context);
388 freecon(newcon); 381 freecon(newcon);
389 free(my_file_orig); 382 free(my_file);
390 return retval; 383 return retval;
391 err: 384 err:
392 retval--; /* -1 */ 385 retval--; /* -1 */
@@ -499,7 +492,6 @@ int setfiles_main(int argc, char **argv)
499 struct stat sb; 492 struct stat sb;
500 int rc, i = 0; 493 int rc, i = 0;
501 const char *input_filename = NULL; 494 const char *input_filename = NULL;
502 int use_input_file = 0;
503 char *buf = NULL; 495 char *buf = NULL;
504 size_t buf_len; 496 size_t buf_len;
505 int flags; 497 int flags;
@@ -591,7 +583,6 @@ int setfiles_main(int argc, char **argv)
591 rootpathlen = strlen(rootpath); 583 rootpathlen = strlen(rootpath);
592 } 584 }
593 if (flags & OPT_s) { 585 if (flags & OPT_s) {
594 use_input_file = 1;
595 input_filename = "-"; 586 input_filename = "-";
596 add_assoc = 0; 587 add_assoc = 0;
597 } 588 }
@@ -621,7 +612,7 @@ int setfiles_main(int argc, char **argv)
621 exit(1); 612 exit(1);
622 } 613 }
623 614
624 if (use_input_file) { 615 if (input_filename) {
625 ssize_t len; 616 ssize_t len;
626 FILE *f = stdin; 617 FILE *f = stdin;
627 618