svn commit: trunk/busybox/selinux
vda at busybox.net
vda at busybox.net
Sun Aug 5 19:36:37 PDT 2007
Author: vda
Date: 2007-08-05 19:36:35 -0700 (Sun, 05 Aug 2007)
New Revision: 19407
Log:
setfiles:
* Bug fix: -f option did not work.
* Using bb_simplify_path to remove extra slash for smaller code.
(by Yuichi Nakamura <ynakam at hitachisoft.jp>)
Modified:
trunk/busybox/selinux/setfiles.c
Changeset:
Modified: trunk/busybox/selinux/setfiles.c
===================================================================
--- trunk/busybox/selinux/setfiles.c 2007-08-05 14:00:05 UTC (rev 19406)
+++ trunk/busybox/selinux/setfiles.c 2007-08-06 02:36:35 UTC (rev 19407)
@@ -264,28 +264,21 @@
static int restore(const char *file)
{
- char *my_file = xstrdup(file);
- char *my_file_orig = my_file;
+ char *my_file;
struct stat my_sb;
int i, j, ret;
char *context = NULL;
char *newcon = NULL;
bool user_only_changed = 0;
- size_t len = strlen(my_file);
int retval = 0;
+
+ my_file = bb_simplify_path(file);
- /* Skip the extra slashes at the beginning and end, if present. */
- if (file[0] == '/' && file[1] == '/')
- my_file++;
- if (len > 1 && my_file[len - 1] == '/')
- my_file[len - 1] = '\0';
-
i = match(my_file, &my_sb, &newcon);
if (i < 0) /* No matching specification. */
goto out;
-
if (FLAG_p_progress) {
count++;
if (count % 0x400 == 0) { /* every 1024 times */
@@ -386,7 +379,7 @@
out:
freecon(context);
freecon(newcon);
- free(my_file_orig);
+ free(my_file);
return retval;
err:
retval--; /* -1 */
@@ -499,7 +492,6 @@
struct stat sb;
int rc, i = 0;
const char *input_filename = NULL;
- int use_input_file = 0;
char *buf = NULL;
size_t buf_len;
int flags;
@@ -591,7 +583,6 @@
rootpathlen = strlen(rootpath);
}
if (flags & OPT_s) {
- use_input_file = 1;
input_filename = "-";
add_assoc = 0;
}
@@ -621,7 +612,7 @@
exit(1);
}
- if (use_input_file) {
+ if (input_filename) {
ssize_t len;
FILE *f = stdin;
More information about the busybox-cvs
mailing list