aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-09-03 21:54:46 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-09-03 21:54:46 +0000
commitd4b719878f5a08986d0a3dc493aad90d4466752e (patch)
tree64d7c96a59ae67227884cd26662eff01762edb6e
parenta2e1eea189981e03b2590c2cd59b9ae65a9cea4f (diff)
downloadbusybox-w32-d4b719878f5a08986d0a3dc493aad90d4466752e.tar.gz
busybox-w32-d4b719878f5a08986d0a3dc493aad90d4466752e.tar.bz2
busybox-w32-d4b719878f5a08986d0a3dc493aad90d4466752e.zip
kbd_mode: fix non-ASCII letters in comments
install: support -D
-rw-r--r--console-tools/kbd_mode.c2
-rw-r--r--coreutils/install.c64
-rw-r--r--include/usage.h15
3 files changed, 46 insertions, 35 deletions
diff --git a/console-tools/kbd_mode.c b/console-tools/kbd_mode.c
index cb97947ce..13a82d7fa 100644
--- a/console-tools/kbd_mode.c
+++ b/console-tools/kbd_mode.c
@@ -2,7 +2,7 @@
2/* 2/*
3 * Mini kbd_mode implementation for busybox 3 * Mini kbd_mode implementation for busybox
4 * 4 *
5 * Copyright (C) 2007 Loïc Grenié <loic.grenie@gmail.com> 5 * Copyright (C) 2007 Loic Grenie <loic.grenie@gmail.com>
6 * written using Andries Brouwer <aeb@cwi.nl>'s kbd_mode from 6 * written using Andries Brouwer <aeb@cwi.nl>'s kbd_mode from
7 * console-utils v0.2.3, licensed under GNU GPLv2 7 * console-utils v0.2.3, licensed under GNU GPLv2
8 * 8 *
diff --git a/coreutils/install.c b/coreutils/install.c
index e99f1a3bd..69bf7dc55 100644
--- a/coreutils/install.c
+++ b/coreutils/install.c
@@ -4,9 +4,6 @@
4 * SELinux support: by Yuichi Nakamura <ynakam@hitachisoft.jp> 4 * SELinux support: by Yuichi Nakamura <ynakam@hitachisoft.jp>
5 * 5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
7 *
8 * TODO: -d option, need a way of recursively making directories and changing
9 * owner/group, will probably modify bb_make_directory(...)
10 */ 7 */
11 8
12#include "libbb.h" 9#include "libbb.h"
@@ -53,7 +50,8 @@ static void setdefaultfilecon(const char *path)
53 50
54 if (lsetfilecon(path, scontext) < 0) { 51 if (lsetfilecon(path, scontext) < 0) {
55 if (errno != ENOTSUP) { 52 if (errno != ENOTSUP) {
56 bb_perror_msg("warning: failed to change context of %s to %s", path, scontext); 53 bb_perror_msg("warning: failed to change context"
54 " of %s to %s", path, scontext);
57 } 55 }
58 } 56 }
59 57
@@ -75,7 +73,7 @@ int install_main(int argc, char **argv)
75 const char *uid_str; 73 const char *uid_str;
76 const char *mode_str; 74 const char *mode_str;
77 int copy_flags = FILEUTILS_DEREFERENCE | FILEUTILS_FORCE; 75 int copy_flags = FILEUTILS_DEREFERENCE | FILEUTILS_FORCE;
78 int flags; 76 int opts;
79 int min_args = 1; 77 int min_args = 1;
80 int ret = EXIT_SUCCESS; 78 int ret = EXIT_SUCCESS;
81 int isdir = 0; 79 int isdir = 0;
@@ -87,15 +85,16 @@ int install_main(int argc, char **argv)
87 OPT_c = 1 << 0, 85 OPT_c = 1 << 0,
88 OPT_v = 1 << 1, 86 OPT_v = 1 << 1,
89 OPT_b = 1 << 2, 87 OPT_b = 1 << 2,
90 OPT_DIRECTORY = 1 << 3, 88 OPT_MKDIR_LEADING = 1 << 3,
91 OPT_PRESERVE_TIME = 1 << 4, 89 OPT_DIRECTORY = 1 << 4,
92 OPT_STRIP = 1 << 5, 90 OPT_PRESERVE_TIME = 1 << 5,
93 OPT_GROUP = 1 << 6, 91 OPT_STRIP = 1 << 6,
94 OPT_MODE = 1 << 7, 92 OPT_GROUP = 1 << 7,
95 OPT_OWNER = 1 << 8, 93 OPT_MODE = 1 << 8,
94 OPT_OWNER = 1 << 9,
96#if ENABLE_SELINUX 95#if ENABLE_SELINUX
97 OPT_SET_SECURITY_CONTEXT = 1 << 9, 96 OPT_SET_SECURITY_CONTEXT = 1 << 10,
98 OPT_PRESERVE_SECURITY_CONTEXT = 1 << 10, 97 OPT_PRESERVE_SECURITY_CONTEXT = 1 << 11,
99#endif 98#endif
100 }; 99 };
101 100
@@ -106,37 +105,38 @@ int install_main(int argc, char **argv)
106 /* -c exists for backwards compatibility, it's needed */ 105 /* -c exists for backwards compatibility, it's needed */
107 /* -v is ignored ("print name of each created directory") */ 106 /* -v is ignored ("print name of each created directory") */
108 /* -b is ignored ("make a backup of each existing destination file") */ 107 /* -b is ignored ("make a backup of each existing destination file") */
109 flags = getopt32(argv, "cvb" "dpsg:m:o:" USE_SELINUX("Z:"), 108 opts = getopt32(argv, "cvb" "Ddpsg:m:o:" USE_SELINUX("Z:"),
110 &gid_str, &mode_str, &uid_str USE_SELINUX(, &scontext)); 109 &gid_str, &mode_str, &uid_str USE_SELINUX(, &scontext));
111 argc -= optind; 110 argc -= optind;
112 argv += optind; 111 argv += optind;
113 112
114#if ENABLE_SELINUX 113#if ENABLE_SELINUX
115 if (flags & (OPT_PRESERVE_SECURITY_CONTEXT|OPT_SET_SECURITY_CONTEXT)) { 114 if (opts & (OPT_PRESERVE_SECURITY_CONTEXT|OPT_SET_SECURITY_CONTEXT)) {
116 selinux_or_die(); 115 selinux_or_die();
117 use_default_selinux_context = 0; 116 use_default_selinux_context = 0;
118 if (flags & OPT_PRESERVE_SECURITY_CONTEXT) { 117 if (opts & OPT_PRESERVE_SECURITY_CONTEXT) {
119 copy_flags |= FILEUTILS_PRESERVE_SECURITY_CONTEXT; 118 copy_flags |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;
120 } 119 }
121 if (flags & OPT_SET_SECURITY_CONTEXT) { 120 if (opts & OPT_SET_SECURITY_CONTEXT) {
122 setfscreatecon_or_die(scontext); 121 setfscreatecon_or_die(scontext);
123 copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT; 122 copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT;
124 } 123 }
125 } 124 }
126#endif 125#endif
127 126
128 /* preserve access and modification time, this is GNU behaviour, BSD only preserves modification time */ 127 /* preserve access and modification time, this is GNU behaviour,
129 if (flags & OPT_PRESERVE_TIME) { 128 * BSD only preserves modification time */
129 if (opts & OPT_PRESERVE_TIME) {
130 copy_flags |= FILEUTILS_PRESERVE_STATUS; 130 copy_flags |= FILEUTILS_PRESERVE_STATUS;
131 } 131 }
132 mode = 0666; 132 mode = 0666;
133 if (flags & OPT_MODE) 133 if (opts & OPT_MODE)
134 bb_parse_mode(mode_str, &mode); 134 bb_parse_mode(mode_str, &mode);
135 uid = (flags & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid(); 135 uid = (opts & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid();
136 gid = (flags & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid(); 136 gid = (opts & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid();
137 137
138 last = argv[argc - 1]; 138 last = argv[argc - 1];
139 if (!(flags & OPT_DIRECTORY)) { 139 if (!(opts & OPT_DIRECTORY)) {
140 argv[argc - 1] = NULL; 140 argv[argc - 1] = NULL;
141 min_args++; 141 min_args++;
142 142
@@ -149,7 +149,7 @@ int install_main(int argc, char **argv)
149 149
150 while ((arg = *argv++) != NULL) { 150 while ((arg = *argv++) != NULL) {
151 char *dest = last; 151 char *dest = last;
152 if (flags & OPT_DIRECTORY) { 152 if (opts & OPT_DIRECTORY) {
153 dest = arg; 153 dest = arg;
154 /* GNU coreutils 6.9 does not set uid:gid 154 /* GNU coreutils 6.9 does not set uid:gid
155 * on intermediate created directories 155 * on intermediate created directories
@@ -161,6 +161,16 @@ int install_main(int argc, char **argv)
161 } else { 161 } else {
162 if (isdir) 162 if (isdir)
163 dest = concat_path_file(last, basename(arg)); 163 dest = concat_path_file(last, basename(arg));
164 if (opts & OPT_MKDIR_LEADING) {
165 char *slash = strrchr(dest, '/');
166 if (slash) {
167 *slash = '\0';
168 bb_make_directory(dest, 0755, FILEUTILS_RECUR);
169 /* errors are not checked. copy_file
170 * will fail if dir is not created. */
171 *slash = '/';
172 }
173 }
164 if (copy_file(arg, dest, copy_flags)) { 174 if (copy_file(arg, dest, copy_flags)) {
165 /* copy is not made */ 175 /* copy is not made */
166 ret = EXIT_FAILURE; 176 ret = EXIT_FAILURE;
@@ -169,7 +179,7 @@ int install_main(int argc, char **argv)
169 } 179 }
170 180
171 /* Set the file mode */ 181 /* Set the file mode */
172 if ((flags & OPT_MODE) && chmod(dest, mode) == -1) { 182 if ((opts & OPT_MODE) && chmod(dest, mode) == -1) {
173 bb_perror_msg("can't change %s of %s", "permissions", dest); 183 bb_perror_msg("can't change %s of %s", "permissions", dest);
174 ret = EXIT_FAILURE; 184 ret = EXIT_FAILURE;
175 } 185 }
@@ -178,13 +188,13 @@ int install_main(int argc, char **argv)
178 setdefaultfilecon(dest); 188 setdefaultfilecon(dest);
179#endif 189#endif
180 /* Set the user and group id */ 190 /* Set the user and group id */
181 if ((flags & (OPT_OWNER|OPT_GROUP)) 191 if ((opts & (OPT_OWNER|OPT_GROUP))
182 && lchown(dest, uid, gid) == -1 192 && lchown(dest, uid, gid) == -1
183 ) { 193 ) {
184 bb_perror_msg("can't change %s of %s", "ownership", dest); 194 bb_perror_msg("can't change %s of %s", "ownership", dest);
185 ret = EXIT_FAILURE; 195 ret = EXIT_FAILURE;
186 } 196 }
187 if (flags & OPT_STRIP) { 197 if (opts & OPT_STRIP) {
188 char *args[3]; 198 char *args[3];
189 args[0] = (char*)"strip"; 199 args[0] = (char*)"strip";
190 args[1] = dest; 200 args[1] = dest;
diff --git a/include/usage.h b/include/usage.h
index b901090b8..47a648f21 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -1873,19 +1873,20 @@
1873 ) 1873 )
1874 1874
1875#define install_trivial_usage \ 1875#define install_trivial_usage \
1876 "[-cgmops] [sources] dest|directory" 1876 "[-cdDsp] [-o USER] [-g GRP] [-m MODE] [source] dest|directory"
1877#define install_full_usage "\n\n" \ 1877#define install_full_usage "\n\n" \
1878 "Copy files and set attributes\n" \ 1878 "Copy files and set attributes\n" \
1879 "\nOptions:" \ 1879 "\nOptions:" \
1880 "\n -c Copy the file, default" \ 1880 "\n -c Just copy (default)" \
1881 "\n -d Create directories" \ 1881 "\n -d Create directories" \
1882 "\n -g Set group ownership" \ 1882 "\n -D Create leading directories" \
1883 "\n -m Set permissions" \ 1883 "\n -s Strip symbol table" \
1884 "\n -o Set ownership" \
1885 "\n -p Preserve date" \ 1884 "\n -p Preserve date" \
1886 "\n -s Strip symbol tables" \ 1885 "\n -o USER Set ownership" \
1886 "\n -g GRP Set group ownership" \
1887 "\n -m MODE Set permissions" \
1887 USE_SELINUX( \ 1888 USE_SELINUX( \
1888 "\n -Z Set security context of copy" \ 1889 "\n -Z Set security context" \
1889 ) 1890 )
1890 1891
1891/* would need to make the " | " optional depending on more than one selected: */ 1892/* would need to make the " | " optional depending on more than one selected: */