diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-13 18:56:42 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-13 18:56:42 +0000 |
commit | 1b61f41f577a247c7a9534c56966e796facf1494 (patch) | |
tree | a2008aca5c711f72c9b29b5b4372de074fc5da32 | |
parent | 21943ce6416215ff1a2df7b5008460bf9099f478 (diff) | |
download | busybox-w32-1b61f41f577a247c7a9534c56966e796facf1494.tar.gz busybox-w32-1b61f41f577a247c7a9534c56966e796facf1494.tar.bz2 busybox-w32-1b61f41f577a247c7a9534c56966e796facf1494.zip |
More stuff
-rw-r--r-- | applets/busybox.c | 10 | ||||
-rw-r--r-- | archival/tar.c | 2 | ||||
-rw-r--r-- | busybox.c | 10 | ||||
-rw-r--r-- | busybox.def.h | 3 | ||||
-rw-r--r-- | chmod.c | 161 | ||||
-rw-r--r-- | chown.c | 191 | ||||
-rw-r--r-- | coreutils/chmod.c | 161 | ||||
-rw-r--r-- | coreutils/chown.c | 191 | ||||
-rw-r--r-- | internal.h | 4 | ||||
-rw-r--r-- | tar.c | 2 |
10 files changed, 528 insertions, 207 deletions
diff --git a/applets/busybox.c b/applets/busybox.c index 0892e84ec..561aa01b5 100644 --- a/applets/busybox.c +++ b/applets/busybox.c | |||
@@ -16,12 +16,10 @@ static const struct Applet applets[] = { | |||
16 | #ifdef BB_CAT //bin | 16 | #ifdef BB_CAT //bin |
17 | {"cat", cat_more_main}, | 17 | {"cat", cat_more_main}, |
18 | #endif | 18 | #endif |
19 | #ifdef BB_CHMOD //bin | 19 | #ifdef BB_CHMOD_CHOWN_CHGRP //bin |
20 | {"chmod", chmod_main}, | 20 | {"chmod", chmod_chown_chgrp_main}, |
21 | #endif | 21 | {"chown", chmod_chown_chgrp_main}, |
22 | #ifdef BB_CHOWN //bin | 22 | {"chgrp", chmod_chown_chgrp_main}, |
23 | {"chown", chown_main}, | ||
24 | {"chgrp", chown_main}, | ||
25 | #endif | 23 | #endif |
26 | #ifdef BB_CHROOT //sbin | 24 | #ifdef BB_CHROOT //sbin |
27 | {"chroot", chroot_main}, | 25 | {"chroot", chroot_main}, |
diff --git a/archival/tar.c b/archival/tar.c index a5a0fab64..ff60f0689 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -844,7 +844,7 @@ static void saveDirectory (const char *dirName, const struct stat *statbuf) | |||
844 | DIR *dir; | 844 | DIR *dir; |
845 | struct dirent *entry; | 845 | struct dirent *entry; |
846 | int needSlash; | 846 | int needSlash; |
847 | char fullName[PATH_LEN]; | 847 | char fullName[NAME_MAX]; |
848 | 848 | ||
849 | /* | 849 | /* |
850 | * Construct the directory name as used in the tar file by appending | 850 | * Construct the directory name as used in the tar file by appending |
@@ -16,12 +16,10 @@ static const struct Applet applets[] = { | |||
16 | #ifdef BB_CAT //bin | 16 | #ifdef BB_CAT //bin |
17 | {"cat", cat_more_main}, | 17 | {"cat", cat_more_main}, |
18 | #endif | 18 | #endif |
19 | #ifdef BB_CHMOD //bin | 19 | #ifdef BB_CHMOD_CHOWN_CHGRP //bin |
20 | {"chmod", chmod_main}, | 20 | {"chmod", chmod_chown_chgrp_main}, |
21 | #endif | 21 | {"chown", chmod_chown_chgrp_main}, |
22 | #ifdef BB_CHOWN //bin | 22 | {"chgrp", chmod_chown_chgrp_main}, |
23 | {"chown", chown_main}, | ||
24 | {"chgrp", chown_main}, | ||
25 | #endif | 23 | #endif |
26 | #ifdef BB_CHROOT //sbin | 24 | #ifdef BB_CHROOT //sbin |
27 | {"chroot", chroot_main}, | 25 | {"chroot", chroot_main}, |
diff --git a/busybox.def.h b/busybox.def.h index 090bd7e7c..ae9945d1b 100644 --- a/busybox.def.h +++ b/busybox.def.h | |||
@@ -6,8 +6,7 @@ | |||
6 | //#define BB_BLOCK_DEVICE | 6 | //#define BB_BLOCK_DEVICE |
7 | #define BB_BUSYBOX | 7 | #define BB_BUSYBOX |
8 | #define BB_CAT | 8 | #define BB_CAT |
9 | //#define BB_CHMOD | 9 | #define BB_CHMOD_CHOWN_CHGRP |
10 | #define BB_CHOWN | ||
11 | #define BB_CHROOT | 10 | #define BB_CHROOT |
12 | #define BB_CLEAR | 11 | #define BB_CLEAR |
13 | #define BB_CP | 12 | #define BB_CP |
@@ -1,41 +1,54 @@ | |||
1 | #include <stdlib.h> | 1 | /* |
2 | * Mini chmod implementation for busybox | ||
3 | * | ||
4 | * Copyright (C) 1998 by Erik Andersen <andersee@debian.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
2 | #include <stdio.h> | 22 | #include <stdio.h> |
3 | #include <unistd.h> | 23 | #include <grp.h> |
4 | #include <sys/stat.h> | 24 | #include <pwd.h> |
5 | #include "internal.h" | 25 | #include "internal.h" |
6 | 26 | ||
7 | const char chmod_usage[] = "chmod [-R] mode file [file ...]\n" | 27 | |
8 | "\nmode may be an octal integer representing the bit pattern for the\n" | 28 | static mode_t mode=7777; |
9 | "\tnew mode, or a symbolic value matching the pattern\n" | 29 | |
10 | "\t[ugoa]{+|-|=}[rwxst] .\n" | 30 | |
11 | "\t\tu:\tUser\n" | 31 | static const char chmod_usage[] = "[-R] MODE[,MODE]... FILE...\n" |
12 | "\t\tg:\tGroup\n" | 32 | "Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n" |
13 | "\t\to:\tOthers\n" | 33 | "one or more of the letters rwxst.\n\n" |
14 | "\t\ta:\tAll\n" | 34 | "\t-R\tchange files and directories recursively.\n"; |
15 | "\n" | 35 | |
16 | "\n+:\tAdd privilege\n" | 36 | |
17 | "\n-:\tRemove privilege\n" | 37 | |
18 | "\n=:\tSet privilege\n" | 38 | static int fileAction(const char *fileName) |
19 | "\n" | 39 | { |
20 | "\t\tr:\tRead\n" | 40 | struct stat statBuf; |
21 | "\t\tw:\tWrite\n" | 41 | if ((stat(fileName, &statBuf) < 0) || |
22 | "\t\tx:\tExecute\n" | 42 | (chmod(fileName, mode)) < 0) { |
23 | "\t\ts:\tSet User ID\n" | 43 | perror(fileName); |
24 | "\t\tt:\t\"Sticky\" Text\n" | 44 | return( FALSE); |
25 | "\n" | 45 | } |
26 | "\tModes may be concatenated, as in \"u=rwx,g=rx,o=rx,-t,-s\n" | 46 | return( TRUE); |
27 | "\n" | 47 | } |
28 | "\t-R:\tRecursively change the mode of all files and directories\n" | 48 | |
29 | "\t\tunder the argument directory."; | 49 | /* [ugoa]{+|-|=}[rwxstl] */ |
30 | 50 | int parse_mode( const char* s, mode_t* or, mode_t* and, int* group_execute) | |
31 | int | ||
32 | parse_mode( | ||
33 | const char * s | ||
34 | ,mode_t * or | ||
35 | ,mode_t * and | ||
36 | ,int * group_execute) | ||
37 | { | 51 | { |
38 | /* [ugoa]{+|-|=}[rwxstl] */ | ||
39 | mode_t mode = 0; | 52 | mode_t mode = 0; |
40 | mode_t groups = S_ISVTX; | 53 | mode_t groups = S_ISVTX; |
41 | char type; | 54 | char type; |
@@ -45,7 +58,7 @@ parse_mode( | |||
45 | for ( ; ; ) { | 58 | for ( ; ; ) { |
46 | switch ( c = *s++ ) { | 59 | switch ( c = *s++ ) { |
47 | case '\0': | 60 | case '\0': |
48 | return -1; | 61 | return (FALSE); |
49 | case 'u': | 62 | case 'u': |
50 | groups |= S_ISUID|S_IRWXU; | 63 | groups |= S_ISUID|S_IRWXU; |
51 | continue; | 64 | continue; |
@@ -69,10 +82,10 @@ parse_mode( | |||
69 | if ( c >= '0' && c <= '7' && mode == 0 && groups == S_ISVTX ) { | 82 | if ( c >= '0' && c <= '7' && mode == 0 && groups == S_ISVTX ) { |
70 | *and = 0; | 83 | *and = 0; |
71 | *or = strtol(--s, 0, 010); | 84 | *or = strtol(--s, 0, 010); |
72 | return 0; | 85 | return (TRUE); |
73 | } | 86 | } |
74 | else | 87 | else |
75 | return -1; | 88 | return (FALSE); |
76 | } | 89 | } |
77 | break; | 90 | break; |
78 | } | 91 | } |
@@ -93,7 +106,7 @@ parse_mode( | |||
93 | case 's': | 106 | case 's': |
94 | if ( group_execute != 0 && (groups & S_IRWXG) ) { | 107 | if ( group_execute != 0 && (groups & S_IRWXG) ) { |
95 | if ( *group_execute < 0 ) | 108 | if ( *group_execute < 0 ) |
96 | return -1; | 109 | return (FALSE); |
97 | if ( type != '-' ) { | 110 | if ( type != '-' ) { |
98 | mode |= S_IXGRP; | 111 | mode |= S_IXGRP; |
99 | *group_execute = 1; | 112 | *group_execute = 1; |
@@ -103,7 +116,7 @@ parse_mode( | |||
103 | continue; | 116 | continue; |
104 | case 'l': | 117 | case 'l': |
105 | if ( *group_execute > 0 ) | 118 | if ( *group_execute > 0 ) |
106 | return -1; | 119 | return (FALSE); |
107 | if ( type != '-' ) { | 120 | if ( type != '-' ) { |
108 | *and &= ~S_IXGRP; | 121 | *and &= ~S_IXGRP; |
109 | *group_execute = -1; | 122 | *group_execute = -1; |
@@ -115,7 +128,7 @@ parse_mode( | |||
115 | mode |= S_ISVTX; | 128 | mode |= S_ISVTX; |
116 | continue; | 129 | continue; |
117 | default: | 130 | default: |
118 | return -1; | 131 | return (FALSE); |
119 | } | 132 | } |
120 | break; | 133 | break; |
121 | } | 134 | } |
@@ -132,32 +145,54 @@ parse_mode( | |||
132 | break; | 145 | break; |
133 | } | 146 | } |
134 | } while ( c == ',' ); | 147 | } while ( c == ',' ); |
135 | return 0; | 148 | return (TRUE); |
136 | } | 149 | } |
137 | 150 | ||
138 | extern int | 151 | |
139 | chmod_main(struct FileInfo * i, int argc, char * * argv) | 152 | int chmod_main(int argc, char **argv) |
140 | { | 153 | { |
141 | i->andWithMode = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; | 154 | int recursiveFlag=FALSE; |
142 | i->orWithMode = 0; | 155 | mode_t andWithMode = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; |
143 | 156 | mode_t orWithMode = 0; | |
144 | while ( argc >= 3 ) { | 157 | char *invocationName=*argv; |
145 | if ( parse_mode(argv[1], &i->orWithMode, &i->andWithMode, 0) | ||
146 | == 0 ) { | ||
147 | argc--; | ||
148 | argv++; | ||
149 | } | ||
150 | else if ( strcmp(argv[1], "-R") == 0 ) { | ||
151 | i->recursive = 1; | ||
152 | argc--; | ||
153 | argv++; | ||
154 | } | ||
155 | else | ||
156 | break; | ||
157 | } | ||
158 | 158 | ||
159 | i->changeMode = 1; | 159 | if (argc < 3) { |
160 | i->complainInPostProcess = 1; | 160 | fprintf(stderr, "Usage: %s %s", invocationName, chmod_usage); |
161 | exit( FALSE); | ||
162 | } | ||
163 | argc--; | ||
164 | argv++; | ||
165 | |||
166 | /* Parse options */ | ||
167 | while (**argv == '-') { | ||
168 | while (*++(*argv)) switch (**argv) { | ||
169 | case 'R': | ||
170 | recursiveFlag = TRUE; | ||
171 | break; | ||
172 | default: | ||
173 | fprintf(stderr, "Unknown option: %c\n", **argv); | ||
174 | exit( FALSE); | ||
175 | } | ||
176 | argc--; | ||
177 | argv++; | ||
178 | } | ||
179 | |||
180 | /* Find the selected group */ | ||
181 | if ( parse_mode(*argv, &orWithMode, &andWithMode, 0) == FALSE ) { | ||
182 | fprintf(stderr, "%s: Unknown mode: %s\n", invocationName, *argv); | ||
183 | exit( FALSE); | ||
184 | } | ||
185 | mode &= andWithMode; | ||
186 | mode |= orWithMode; | ||
161 | 187 | ||
162 | return monadic_main(i, argc, argv); | 188 | /* Ok, ready to do the deed now */ |
189 | if (argc <= 1) { | ||
190 | fprintf(stderr, "%s: too few arguments", invocationName); | ||
191 | exit( FALSE); | ||
192 | } | ||
193 | while (argc-- > 1) { | ||
194 | argv++; | ||
195 | recursiveAction( *argv, recursiveFlag, TRUE, fileAction, fileAction); | ||
196 | } | ||
197 | exit(TRUE); | ||
163 | } | 198 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Mini chown/chgrp implementation for busybox | 2 | * Mini chown/chmod/chgrp implementation for busybox |
3 | * | 3 | * |
4 | * Copyright (C) 1998 by Erik Andersen <andersee@debian.org> | 4 | * Copyright (C) 1998 by Erik Andersen <andersee@debian.org> |
5 | * | 5 | * |
@@ -27,33 +27,150 @@ | |||
27 | 27 | ||
28 | static int uid=-1; | 28 | static int uid=-1; |
29 | static int gid=0; | 29 | static int gid=0; |
30 | static int chownApp; | 30 | static int whichApp; |
31 | static char* invocationName=NULL; | 31 | static char* invocationName=NULL; |
32 | static mode_t mode=7777; | ||
32 | 33 | ||
33 | 34 | ||
35 | #define CHGRP_APP 1 | ||
36 | #define CHOWN_APP 2 | ||
37 | #define CHMOD_APP 3 | ||
38 | |||
34 | static const char chgrp_usage[] = "[OPTION]... GROUP FILE...\n" | 39 | static const char chgrp_usage[] = "[OPTION]... GROUP FILE...\n" |
35 | "Change the group membership of each FILE to GROUP.\n" | 40 | "Change the group membership of each FILE to GROUP.\n" |
36 | "\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; | 41 | "\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; |
37 | static const char chown_usage[] = "[OPTION]... OWNER[.[GROUP] FILE...\n" | 42 | static const char chown_usage[] = "[OPTION]... OWNER[.[GROUP] FILE...\n" |
38 | "Change the owner and/or group of each FILE to OWNER and/or GROUP.\n" | 43 | "Change the owner and/or group of each FILE to OWNER and/or GROUP.\n" |
39 | "\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; | 44 | "\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; |
45 | static const char chmod_usage[] = "[-R] MODE[,MODE]... FILE...\n" | ||
46 | "Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n" | ||
47 | "one or more of the letters rwxst.\n\n" | ||
48 | "\t-R\tchange files and directories recursively.\n"; | ||
40 | 49 | ||
41 | 50 | ||
42 | 51 | ||
43 | static int fileAction(const char *fileName) | 52 | static int fileAction(const char *fileName) |
44 | { | 53 | { |
45 | struct stat statBuf; | 54 | struct stat statBuf; |
46 | if ((stat(fileName, &statBuf) < 0) || | 55 | if (stat(fileName, &statBuf) < 0) { |
47 | (chown(fileName, | 56 | switch (whichApp) { |
48 | ((chownApp==TRUE)? uid: statBuf.st_uid), | 57 | case CHGRP_APP: |
49 | gid) < 0)) { | 58 | case CHOWN_APP: |
50 | perror(fileName); | 59 | if (chown(fileName, ((whichApp==CHOWN_APP)? uid: statBuf.st_uid), gid) < 0) |
51 | return( FALSE); | 60 | return( TRUE); |
61 | case CHMOD_APP: | ||
62 | if (chmod(fileName, mode)) | ||
63 | return( TRUE); | ||
64 | } | ||
52 | } | 65 | } |
53 | return( TRUE); | 66 | perror(fileName); |
67 | return( FALSE); | ||
54 | } | 68 | } |
55 | 69 | ||
56 | int chown_main(int argc, char **argv) | 70 | /* [ugoa]{+|-|=}[rwxstl] */ |
71 | int parse_mode( const char* s, mode_t* or, mode_t* and, int* group_execute) | ||
72 | { | ||
73 | mode_t mode = 0; | ||
74 | mode_t groups = S_ISVTX; | ||
75 | char type; | ||
76 | char c; | ||
77 | |||
78 | do { | ||
79 | for ( ; ; ) { | ||
80 | switch ( c = *s++ ) { | ||
81 | case '\0': | ||
82 | return (FALSE); | ||
83 | case 'u': | ||
84 | groups |= S_ISUID|S_IRWXU; | ||
85 | continue; | ||
86 | case 'g': | ||
87 | groups |= S_ISGID|S_IRWXG; | ||
88 | continue; | ||
89 | case 'o': | ||
90 | groups |= S_IRWXO; | ||
91 | continue; | ||
92 | case 'a': | ||
93 | groups |= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; | ||
94 | continue; | ||
95 | case '+': | ||
96 | case '=': | ||
97 | case '-': | ||
98 | type = c; | ||
99 | if ( groups == S_ISVTX ) /* The default is "all" */ | ||
100 | groups |= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; | ||
101 | break; | ||
102 | default: | ||
103 | if ( c >= '0' && c <= '7' && mode == 0 && groups == S_ISVTX ) { | ||
104 | *and = 0; | ||
105 | *or = strtol(--s, 0, 010); | ||
106 | return (TRUE); | ||
107 | } | ||
108 | else | ||
109 | return (FALSE); | ||
110 | } | ||
111 | break; | ||
112 | } | ||
113 | |||
114 | while ( (c = *s++) != '\0' ) { | ||
115 | switch ( c ) { | ||
116 | case ',': | ||
117 | break; | ||
118 | case 'r': | ||
119 | mode |= S_IRUSR|S_IRGRP|S_IROTH; | ||
120 | continue; | ||
121 | case 'w': | ||
122 | mode |= S_IWUSR|S_IWGRP|S_IWOTH; | ||
123 | continue; | ||
124 | case 'x': | ||
125 | mode |= S_IXUSR|S_IXGRP|S_IXOTH; | ||
126 | continue; | ||
127 | case 's': | ||
128 | if ( group_execute != 0 && (groups & S_IRWXG) ) { | ||
129 | if ( *group_execute < 0 ) | ||
130 | return (FALSE); | ||
131 | if ( type != '-' ) { | ||
132 | mode |= S_IXGRP; | ||
133 | *group_execute = 1; | ||
134 | } | ||
135 | } | ||
136 | mode |= S_ISUID|S_ISGID; | ||
137 | continue; | ||
138 | case 'l': | ||
139 | if ( *group_execute > 0 ) | ||
140 | return (FALSE); | ||
141 | if ( type != '-' ) { | ||
142 | *and &= ~S_IXGRP; | ||
143 | *group_execute = -1; | ||
144 | } | ||
145 | mode |= S_ISGID; | ||
146 | groups |= S_ISGID; | ||
147 | continue; | ||
148 | case 't': | ||
149 | mode |= S_ISVTX; | ||
150 | continue; | ||
151 | default: | ||
152 | return (FALSE); | ||
153 | } | ||
154 | break; | ||
155 | } | ||
156 | switch ( type ) { | ||
157 | case '=': | ||
158 | *and &= ~(groups); | ||
159 | /* fall through */ | ||
160 | case '+': | ||
161 | *or |= mode & groups; | ||
162 | break; | ||
163 | case '-': | ||
164 | *and &= ~(mode & groups); | ||
165 | *or &= *and; | ||
166 | break; | ||
167 | } | ||
168 | } while ( c == ',' ); | ||
169 | return (TRUE); | ||
170 | } | ||
171 | |||
172 | |||
173 | int chmod_chown_chgrp_main(int argc, char **argv) | ||
57 | { | 174 | { |
58 | struct group *grp; | 175 | struct group *grp; |
59 | struct passwd *pwd; | 176 | struct passwd *pwd; |
@@ -61,11 +178,11 @@ int chown_main(int argc, char **argv) | |||
61 | char *groupName; | 178 | char *groupName; |
62 | 179 | ||
63 | 180 | ||
64 | chownApp = (strcmp(*argv, "chown")==0)? TRUE : FALSE; | 181 | whichApp = (strcmp(*argv, "chown")==0)? CHOWN_APP : (strcmp(*argv, "chmod")==0)? CHMOD_APP : CHGRP_APP; |
65 | 182 | ||
66 | if (argc < 2) { | 183 | if (argc < 2) { |
67 | fprintf(stderr, "Usage: %s %s", *argv, | 184 | fprintf(stderr, "Usage: %s %s", *argv, |
68 | (chownApp==TRUE)? chown_usage : chgrp_usage); | 185 | (whichApp==TRUE)? chown_usage : chgrp_usage); |
69 | exit( FALSE); | 186 | exit( FALSE); |
70 | } | 187 | } |
71 | invocationName=*argv; | 188 | invocationName=*argv; |
@@ -86,29 +203,40 @@ int chown_main(int argc, char **argv) | |||
86 | argv++; | 203 | argv++; |
87 | } | 204 | } |
88 | 205 | ||
89 | /* Find the selected group */ | 206 | if ( whichApp == CHMOD_APP ) { |
90 | groupName = strchr(*argv, '.'); | 207 | /* Find the specified modes */ |
91 | if ( chownApp==TRUE && groupName ) | 208 | if ( parse_mode(*argv, &orWithMode, &andWithMode, 0) == FALSE ) { |
92 | *groupName++ = '\0'; | 209 | fprintf(stderr, "%s: Unknown mode: %s\n", invocationName, *argv); |
93 | else | 210 | exit( FALSE); |
94 | groupName = *argv; | 211 | } |
95 | grp = getgrnam(groupName); | 212 | mode &= andWithMode; |
96 | if (grp == NULL) { | 213 | mode |= orWithMode; |
97 | fprintf(stderr, "%s: Unknown group name: %s\n", invocationName, groupName); | 214 | } else { |
98 | exit( FALSE); | ||
99 | } | ||
100 | gid = grp->gr_gid; | ||
101 | 215 | ||
102 | /* Find the selected user (if appropriate) */ | 216 | /* Find the selected group */ |
103 | if (chownApp==TRUE) { | 217 | groupName = strchr(*argv, '.'); |
104 | pwd = getpwnam(*argv); | 218 | if ( whichApp==TRUE && groupName ) |
105 | if (pwd == NULL) { | 219 | *groupName++ = '\0'; |
106 | fprintf(stderr, "%s: Unknown user name: %s\n", invocationName, *argv); | 220 | else |
221 | groupName = *argv; | ||
222 | grp = getgrnam(groupName); | ||
223 | if (grp == NULL) { | ||
224 | fprintf(stderr, "%s: Unknown group name: %s\n", invocationName, groupName); | ||
107 | exit( FALSE); | 225 | exit( FALSE); |
108 | } | 226 | } |
109 | uid = pwd->pw_uid; | 227 | gid = grp->gr_gid; |
110 | } | ||
111 | 228 | ||
229 | /* Find the selected user (if appropriate) */ | ||
230 | if (whichApp==TRUE) { | ||
231 | pwd = getpwnam(*argv); | ||
232 | if (pwd == NULL) { | ||
233 | fprintf(stderr, "%s: Unknown user name: %s\n", invocationName, *argv); | ||
234 | exit( FALSE); | ||
235 | } | ||
236 | uid = pwd->pw_uid; | ||
237 | } | ||
238 | } | ||
239 | |||
112 | /* Ok, ready to do the deed now */ | 240 | /* Ok, ready to do the deed now */ |
113 | if (argc <= 1) { | 241 | if (argc <= 1) { |
114 | fprintf(stderr, "%s: too few arguments", invocationName); | 242 | fprintf(stderr, "%s: too few arguments", invocationName); |
@@ -120,3 +248,4 @@ int chown_main(int argc, char **argv) | |||
120 | } | 248 | } |
121 | exit(TRUE); | 249 | exit(TRUE); |
122 | } | 250 | } |
251 | |||
diff --git a/coreutils/chmod.c b/coreutils/chmod.c index 225c92d10..9f84d0d37 100644 --- a/coreutils/chmod.c +++ b/coreutils/chmod.c | |||
@@ -1,41 +1,54 @@ | |||
1 | #include <stdlib.h> | 1 | /* |
2 | * Mini chmod implementation for busybox | ||
3 | * | ||
4 | * Copyright (C) 1998 by Erik Andersen <andersee@debian.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
2 | #include <stdio.h> | 22 | #include <stdio.h> |
3 | #include <unistd.h> | 23 | #include <grp.h> |
4 | #include <sys/stat.h> | 24 | #include <pwd.h> |
5 | #include "internal.h" | 25 | #include "internal.h" |
6 | 26 | ||
7 | const char chmod_usage[] = "chmod [-R] mode file [file ...]\n" | 27 | |
8 | "\nmode may be an octal integer representing the bit pattern for the\n" | 28 | static mode_t mode=7777; |
9 | "\tnew mode, or a symbolic value matching the pattern\n" | 29 | |
10 | "\t[ugoa]{+|-|=}[rwxst] .\n" | 30 | |
11 | "\t\tu:\tUser\n" | 31 | static const char chmod_usage[] = "[-R] MODE[,MODE]... FILE...\n" |
12 | "\t\tg:\tGroup\n" | 32 | "Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n" |
13 | "\t\to:\tOthers\n" | 33 | "one or more of the letters rwxst.\n\n" |
14 | "\t\ta:\tAll\n" | 34 | "\t-R\tchange files and directories recursively.\n"; |
15 | "\n" | 35 | |
16 | "\n+:\tAdd privilege\n" | 36 | |
17 | "\n-:\tRemove privilege\n" | 37 | |
18 | "\n=:\tSet privilege\n" | 38 | static int fileAction(const char *fileName) |
19 | "\n" | 39 | { |
20 | "\t\tr:\tRead\n" | 40 | struct stat statBuf; |
21 | "\t\tw:\tWrite\n" | 41 | if ((stat(fileName, &statBuf) < 0) || |
22 | "\t\tx:\tExecute\n" | 42 | (chmod(fileName, mode)) < 0) { |
23 | "\t\ts:\tSet User ID\n" | 43 | perror(fileName); |
24 | "\t\tt:\t\"Sticky\" Text\n" | 44 | return( FALSE); |
25 | "\n" | 45 | } |
26 | "\tModes may be concatenated, as in \"u=rwx,g=rx,o=rx,-t,-s\n" | 46 | return( TRUE); |
27 | "\n" | 47 | } |
28 | "\t-R:\tRecursively change the mode of all files and directories\n" | 48 | |
29 | "\t\tunder the argument directory."; | 49 | /* [ugoa]{+|-|=}[rwxstl] */ |
30 | 50 | int parse_mode( const char* s, mode_t* or, mode_t* and, int* group_execute) | |
31 | int | ||
32 | parse_mode( | ||
33 | const char * s | ||
34 | ,mode_t * or | ||
35 | ,mode_t * and | ||
36 | ,int * group_execute) | ||
37 | { | 51 | { |
38 | /* [ugoa]{+|-|=}[rwxstl] */ | ||
39 | mode_t mode = 0; | 52 | mode_t mode = 0; |
40 | mode_t groups = S_ISVTX; | 53 | mode_t groups = S_ISVTX; |
41 | char type; | 54 | char type; |
@@ -45,7 +58,7 @@ parse_mode( | |||
45 | for ( ; ; ) { | 58 | for ( ; ; ) { |
46 | switch ( c = *s++ ) { | 59 | switch ( c = *s++ ) { |
47 | case '\0': | 60 | case '\0': |
48 | return -1; | 61 | return (FALSE); |
49 | case 'u': | 62 | case 'u': |
50 | groups |= S_ISUID|S_IRWXU; | 63 | groups |= S_ISUID|S_IRWXU; |
51 | continue; | 64 | continue; |
@@ -69,10 +82,10 @@ parse_mode( | |||
69 | if ( c >= '0' && c <= '7' && mode == 0 && groups == S_ISVTX ) { | 82 | if ( c >= '0' && c <= '7' && mode == 0 && groups == S_ISVTX ) { |
70 | *and = 0; | 83 | *and = 0; |
71 | *or = strtol(--s, 0, 010); | 84 | *or = strtol(--s, 0, 010); |
72 | return 0; | 85 | return (TRUE); |
73 | } | 86 | } |
74 | else | 87 | else |
75 | return -1; | 88 | return (FALSE); |
76 | } | 89 | } |
77 | break; | 90 | break; |
78 | } | 91 | } |
@@ -93,7 +106,7 @@ parse_mode( | |||
93 | case 's': | 106 | case 's': |
94 | if ( group_execute != 0 && (groups & S_IRWXG) ) { | 107 | if ( group_execute != 0 && (groups & S_IRWXG) ) { |
95 | if ( *group_execute < 0 ) | 108 | if ( *group_execute < 0 ) |
96 | return -1; | 109 | return (FALSE); |
97 | if ( type != '-' ) { | 110 | if ( type != '-' ) { |
98 | mode |= S_IXGRP; | 111 | mode |= S_IXGRP; |
99 | *group_execute = 1; | 112 | *group_execute = 1; |
@@ -103,7 +116,7 @@ parse_mode( | |||
103 | continue; | 116 | continue; |
104 | case 'l': | 117 | case 'l': |
105 | if ( *group_execute > 0 ) | 118 | if ( *group_execute > 0 ) |
106 | return -1; | 119 | return (FALSE); |
107 | if ( type != '-' ) { | 120 | if ( type != '-' ) { |
108 | *and &= ~S_IXGRP; | 121 | *and &= ~S_IXGRP; |
109 | *group_execute = -1; | 122 | *group_execute = -1; |
@@ -115,7 +128,7 @@ parse_mode( | |||
115 | mode |= S_ISVTX; | 128 | mode |= S_ISVTX; |
116 | continue; | 129 | continue; |
117 | default: | 130 | default: |
118 | return -1; | 131 | return (FALSE); |
119 | } | 132 | } |
120 | break; | 133 | break; |
121 | } | 134 | } |
@@ -132,32 +145,54 @@ parse_mode( | |||
132 | break; | 145 | break; |
133 | } | 146 | } |
134 | } while ( c == ',' ); | 147 | } while ( c == ',' ); |
135 | return 0; | 148 | return (TRUE); |
136 | } | 149 | } |
137 | 150 | ||
138 | extern int | 151 | |
139 | chmod_main(struct FileInfo * i, int argc, char * * argv) | 152 | int chmod_main(int argc, char **argv) |
140 | { | 153 | { |
141 | i->andWithMode = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; | 154 | int recursiveFlag=FALSE; |
142 | i->orWithMode = 0; | 155 | mode_t andWithMode = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; |
143 | 156 | mode_t orWithMode = 0; | |
144 | while ( argc >= 3 ) { | 157 | char *invocationName=*argv; |
145 | if ( parse_mode(argv[1], &i->orWithMode, &i->andWithMode, 0) | ||
146 | == 0 ) { | ||
147 | argc--; | ||
148 | argv++; | ||
149 | } | ||
150 | else if ( strcmp(argv[1], "-R") == 0 ) { | ||
151 | i->recursive = 1; | ||
152 | argc--; | ||
153 | argv++; | ||
154 | } | ||
155 | else | ||
156 | break; | ||
157 | } | ||
158 | 158 | ||
159 | i->changeMode = 1; | 159 | if (argc < 3) { |
160 | i->complainInPostProcess = 1; | 160 | fprintf(stderr, "Usage: %s %s", invocationName, chmod_usage); |
161 | exit( FALSE); | ||
162 | } | ||
163 | argc--; | ||
164 | argv++; | ||
165 | |||
166 | /* Parse options */ | ||
167 | while (**argv == '-') { | ||
168 | while (*++(*argv)) switch (**argv) { | ||
169 | case 'R': | ||
170 | recursiveFlag = TRUE; | ||
171 | break; | ||
172 | default: | ||
173 | fprintf(stderr, "Unknown option: %c\n", **argv); | ||
174 | exit( FALSE); | ||
175 | } | ||
176 | argc--; | ||
177 | argv++; | ||
178 | } | ||
179 | |||
180 | /* Find the selected group */ | ||
181 | if ( parse_mode(*argv, &orWithMode, &andWithMode, 0) == FALSE ) { | ||
182 | fprintf(stderr, "%s: Unknown mode: %s\n", invocationName, *argv); | ||
183 | exit( FALSE); | ||
184 | } | ||
185 | mode &= andWithMode; | ||
186 | mode |= orWithMode; | ||
161 | 187 | ||
162 | return monadic_main(i, argc, argv); | 188 | /* Ok, ready to do the deed now */ |
189 | if (argc <= 1) { | ||
190 | fprintf(stderr, "%s: too few arguments", invocationName); | ||
191 | exit( FALSE); | ||
192 | } | ||
193 | while (argc-- > 1) { | ||
194 | argv++; | ||
195 | recursiveAction( *argv, recursiveFlag, TRUE, fileAction, fileAction); | ||
196 | } | ||
197 | exit(TRUE); | ||
163 | } | 198 | } |
diff --git a/coreutils/chown.c b/coreutils/chown.c index 8d6cffa14..76f3333e3 100644 --- a/coreutils/chown.c +++ b/coreutils/chown.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Mini chown/chgrp implementation for busybox | 2 | * Mini chown/chmod/chgrp implementation for busybox |
3 | * | 3 | * |
4 | * Copyright (C) 1998 by Erik Andersen <andersee@debian.org> | 4 | * Copyright (C) 1998 by Erik Andersen <andersee@debian.org> |
5 | * | 5 | * |
@@ -27,33 +27,150 @@ | |||
27 | 27 | ||
28 | static int uid=-1; | 28 | static int uid=-1; |
29 | static int gid=0; | 29 | static int gid=0; |
30 | static int chownApp; | 30 | static int whichApp; |
31 | static char* invocationName=NULL; | 31 | static char* invocationName=NULL; |
32 | static mode_t mode=7777; | ||
32 | 33 | ||
33 | 34 | ||
35 | #define CHGRP_APP 1 | ||
36 | #define CHOWN_APP 2 | ||
37 | #define CHMOD_APP 3 | ||
38 | |||
34 | static const char chgrp_usage[] = "[OPTION]... GROUP FILE...\n" | 39 | static const char chgrp_usage[] = "[OPTION]... GROUP FILE...\n" |
35 | "Change the group membership of each FILE to GROUP.\n" | 40 | "Change the group membership of each FILE to GROUP.\n" |
36 | "\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; | 41 | "\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; |
37 | static const char chown_usage[] = "[OPTION]... OWNER[.[GROUP] FILE...\n" | 42 | static const char chown_usage[] = "[OPTION]... OWNER[.[GROUP] FILE...\n" |
38 | "Change the owner and/or group of each FILE to OWNER and/or GROUP.\n" | 43 | "Change the owner and/or group of each FILE to OWNER and/or GROUP.\n" |
39 | "\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; | 44 | "\n\tOptions:\n" "\t-R\tchange files and directories recursively\n"; |
45 | static const char chmod_usage[] = "[-R] MODE[,MODE]... FILE...\n" | ||
46 | "Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n" | ||
47 | "one or more of the letters rwxst.\n\n" | ||
48 | "\t-R\tchange files and directories recursively.\n"; | ||
40 | 49 | ||
41 | 50 | ||
42 | 51 | ||
43 | static int fileAction(const char *fileName) | 52 | static int fileAction(const char *fileName) |
44 | { | 53 | { |
45 | struct stat statBuf; | 54 | struct stat statBuf; |
46 | if ((stat(fileName, &statBuf) < 0) || | 55 | if (stat(fileName, &statBuf) < 0) { |
47 | (chown(fileName, | 56 | switch (whichApp) { |
48 | ((chownApp==TRUE)? uid: statBuf.st_uid), | 57 | case CHGRP_APP: |
49 | gid) < 0)) { | 58 | case CHOWN_APP: |
50 | perror(fileName); | 59 | if (chown(fileName, ((whichApp==CHOWN_APP)? uid: statBuf.st_uid), gid) < 0) |
51 | return( FALSE); | 60 | return( TRUE); |
61 | case CHMOD_APP: | ||
62 | if (chmod(fileName, mode)) | ||
63 | return( TRUE); | ||
64 | } | ||
52 | } | 65 | } |
53 | return( TRUE); | 66 | perror(fileName); |
67 | return( FALSE); | ||
54 | } | 68 | } |
55 | 69 | ||
56 | int chown_main(int argc, char **argv) | 70 | /* [ugoa]{+|-|=}[rwxstl] */ |
71 | int parse_mode( const char* s, mode_t* or, mode_t* and, int* group_execute) | ||
72 | { | ||
73 | mode_t mode = 0; | ||
74 | mode_t groups = S_ISVTX; | ||
75 | char type; | ||
76 | char c; | ||
77 | |||
78 | do { | ||
79 | for ( ; ; ) { | ||
80 | switch ( c = *s++ ) { | ||
81 | case '\0': | ||
82 | return (FALSE); | ||
83 | case 'u': | ||
84 | groups |= S_ISUID|S_IRWXU; | ||
85 | continue; | ||
86 | case 'g': | ||
87 | groups |= S_ISGID|S_IRWXG; | ||
88 | continue; | ||
89 | case 'o': | ||
90 | groups |= S_IRWXO; | ||
91 | continue; | ||
92 | case 'a': | ||
93 | groups |= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; | ||
94 | continue; | ||
95 | case '+': | ||
96 | case '=': | ||
97 | case '-': | ||
98 | type = c; | ||
99 | if ( groups == S_ISVTX ) /* The default is "all" */ | ||
100 | groups |= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; | ||
101 | break; | ||
102 | default: | ||
103 | if ( c >= '0' && c <= '7' && mode == 0 && groups == S_ISVTX ) { | ||
104 | *and = 0; | ||
105 | *or = strtol(--s, 0, 010); | ||
106 | return (TRUE); | ||
107 | } | ||
108 | else | ||
109 | return (FALSE); | ||
110 | } | ||
111 | break; | ||
112 | } | ||
113 | |||
114 | while ( (c = *s++) != '\0' ) { | ||
115 | switch ( c ) { | ||
116 | case ',': | ||
117 | break; | ||
118 | case 'r': | ||
119 | mode |= S_IRUSR|S_IRGRP|S_IROTH; | ||
120 | continue; | ||
121 | case 'w': | ||
122 | mode |= S_IWUSR|S_IWGRP|S_IWOTH; | ||
123 | continue; | ||
124 | case 'x': | ||
125 | mode |= S_IXUSR|S_IXGRP|S_IXOTH; | ||
126 | continue; | ||
127 | case 's': | ||
128 | if ( group_execute != 0 && (groups & S_IRWXG) ) { | ||
129 | if ( *group_execute < 0 ) | ||
130 | return (FALSE); | ||
131 | if ( type != '-' ) { | ||
132 | mode |= S_IXGRP; | ||
133 | *group_execute = 1; | ||
134 | } | ||
135 | } | ||
136 | mode |= S_ISUID|S_ISGID; | ||
137 | continue; | ||
138 | case 'l': | ||
139 | if ( *group_execute > 0 ) | ||
140 | return (FALSE); | ||
141 | if ( type != '-' ) { | ||
142 | *and &= ~S_IXGRP; | ||
143 | *group_execute = -1; | ||
144 | } | ||
145 | mode |= S_ISGID; | ||
146 | groups |= S_ISGID; | ||
147 | continue; | ||
148 | case 't': | ||
149 | mode |= S_ISVTX; | ||
150 | continue; | ||
151 | default: | ||
152 | return (FALSE); | ||
153 | } | ||
154 | break; | ||
155 | } | ||
156 | switch ( type ) { | ||
157 | case '=': | ||
158 | *and &= ~(groups); | ||
159 | /* fall through */ | ||
160 | case '+': | ||
161 | *or |= mode & groups; | ||
162 | break; | ||
163 | case '-': | ||
164 | *and &= ~(mode & groups); | ||
165 | *or &= *and; | ||
166 | break; | ||
167 | } | ||
168 | } while ( c == ',' ); | ||
169 | return (TRUE); | ||
170 | } | ||
171 | |||
172 | |||
173 | int chmod_chown_chgrp_main(int argc, char **argv) | ||
57 | { | 174 | { |
58 | struct group *grp; | 175 | struct group *grp; |
59 | struct passwd *pwd; | 176 | struct passwd *pwd; |
@@ -61,11 +178,11 @@ int chown_main(int argc, char **argv) | |||
61 | char *groupName; | 178 | char *groupName; |
62 | 179 | ||
63 | 180 | ||
64 | chownApp = (strcmp(*argv, "chown")==0)? TRUE : FALSE; | 181 | whichApp = (strcmp(*argv, "chown")==0)? CHOWN_APP : (strcmp(*argv, "chmod")==0)? CHMOD_APP : CHGRP_APP; |
65 | 182 | ||
66 | if (argc < 2) { | 183 | if (argc < 2) { |
67 | fprintf(stderr, "Usage: %s %s", *argv, | 184 | fprintf(stderr, "Usage: %s %s", *argv, |
68 | (chownApp==TRUE)? chown_usage : chgrp_usage); | 185 | (whichApp==TRUE)? chown_usage : chgrp_usage); |
69 | exit( FALSE); | 186 | exit( FALSE); |
70 | } | 187 | } |
71 | invocationName=*argv; | 188 | invocationName=*argv; |
@@ -86,29 +203,40 @@ int chown_main(int argc, char **argv) | |||
86 | argv++; | 203 | argv++; |
87 | } | 204 | } |
88 | 205 | ||
89 | /* Find the selected group */ | 206 | if ( whichApp == CHMOD_APP ) { |
90 | groupName = strchr(*argv, '.'); | 207 | /* Find the specified modes */ |
91 | if ( chownApp==TRUE && groupName ) | 208 | if ( parse_mode(*argv, &orWithMode, &andWithMode, 0) == FALSE ) { |
92 | *groupName++ = '\0'; | 209 | fprintf(stderr, "%s: Unknown mode: %s\n", invocationName, *argv); |
93 | else | 210 | exit( FALSE); |
94 | groupName = *argv; | 211 | } |
95 | grp = getgrnam(groupName); | 212 | mode &= andWithMode; |
96 | if (grp == NULL) { | 213 | mode |= orWithMode; |
97 | fprintf(stderr, "%s: Unknown group name: %s\n", invocationName, groupName); | 214 | } else { |
98 | exit( FALSE); | ||
99 | } | ||
100 | gid = grp->gr_gid; | ||
101 | 215 | ||
102 | /* Find the selected user (if appropriate) */ | 216 | /* Find the selected group */ |
103 | if (chownApp==TRUE) { | 217 | groupName = strchr(*argv, '.'); |
104 | pwd = getpwnam(*argv); | 218 | if ( whichApp==TRUE && groupName ) |
105 | if (pwd == NULL) { | 219 | *groupName++ = '\0'; |
106 | fprintf(stderr, "%s: Unknown user name: %s\n", invocationName, *argv); | 220 | else |
221 | groupName = *argv; | ||
222 | grp = getgrnam(groupName); | ||
223 | if (grp == NULL) { | ||
224 | fprintf(stderr, "%s: Unknown group name: %s\n", invocationName, groupName); | ||
107 | exit( FALSE); | 225 | exit( FALSE); |
108 | } | 226 | } |
109 | uid = pwd->pw_uid; | 227 | gid = grp->gr_gid; |
110 | } | ||
111 | 228 | ||
229 | /* Find the selected user (if appropriate) */ | ||
230 | if (whichApp==TRUE) { | ||
231 | pwd = getpwnam(*argv); | ||
232 | if (pwd == NULL) { | ||
233 | fprintf(stderr, "%s: Unknown user name: %s\n", invocationName, *argv); | ||
234 | exit( FALSE); | ||
235 | } | ||
236 | uid = pwd->pw_uid; | ||
237 | } | ||
238 | } | ||
239 | |||
112 | /* Ok, ready to do the deed now */ | 240 | /* Ok, ready to do the deed now */ |
113 | if (argc <= 1) { | 241 | if (argc <= 1) { |
114 | fprintf(stderr, "%s: too few arguments", invocationName); | 242 | fprintf(stderr, "%s: too few arguments", invocationName); |
@@ -120,3 +248,4 @@ int chown_main(int argc, char **argv) | |||
120 | } | 248 | } |
121 | exit(TRUE); | 249 | exit(TRUE); |
122 | } | 250 | } |
251 | |||
diff --git a/internal.h b/internal.h index a67c22339..f095091fc 100644 --- a/internal.h +++ b/internal.h | |||
@@ -59,9 +59,7 @@ extern int block_device_main(int argc, char** argv); | |||
59 | extern int cat_more_main(int argc, char** argv); | 59 | extern int cat_more_main(int argc, char** argv); |
60 | extern int more_main(int argc, char** argv); | 60 | extern int more_main(int argc, char** argv); |
61 | extern int cp_main(int argc, char** argv); | 61 | extern int cp_main(int argc, char** argv); |
62 | extern int chgrp_main(int argc, char** argv); | 62 | extern int chmod_chown_chgrp_main(int argc, char** argv); |
63 | extern int chmod_main(int argc, char** argv); | ||
64 | extern int chown_main(int argc, char** argv); | ||
65 | extern int chroot_main(int argc, char** argv); | 63 | extern int chroot_main(int argc, char** argv); |
66 | extern int clear_main(int argc, char** argv); | 64 | extern int clear_main(int argc, char** argv); |
67 | extern int date_main(int argc, char** argv); | 65 | extern int date_main(int argc, char** argv); |
@@ -844,7 +844,7 @@ static void saveDirectory (const char *dirName, const struct stat *statbuf) | |||
844 | DIR *dir; | 844 | DIR *dir; |
845 | struct dirent *entry; | 845 | struct dirent *entry; |
846 | int needSlash; | 846 | int needSlash; |
847 | char fullName[PATH_LEN]; | 847 | char fullName[NAME_MAX]; |
848 | 848 | ||
849 | /* | 849 | /* |
850 | * Construct the directory name as used in the tar file by appending | 850 | * Construct the directory name as used in the tar file by appending |