aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-10-15 08:29:17 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-10-15 08:29:17 +0000
commitcfdb711a18f0f713fe803d3e3e22a95bed193ceb (patch)
tree6142c84237260e348fe728f95453603ad106dcde
parent58cc52aa76462d668a37af8e5ae70a190e54f105 (diff)
downloadbusybox-w32-cfdb711a18f0f713fe803d3e3e22a95bed193ceb.tar.gz
busybox-w32-cfdb711a18f0f713fe803d3e3e22a95bed193ceb.tar.bz2
busybox-w32-cfdb711a18f0f713fe803d3e3e22a95bed193ceb.zip
sysctl: remove special-cased reporting of EPERM,
common code path gives nearly the same message. -50 bytes
-rw-r--r--procps/sysctl.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/procps/sysctl.c b/procps/sysctl.c
index 18caa2c11..c095d16d0 100644
--- a/procps/sysctl.c
+++ b/procps/sysctl.c
@@ -1,4 +1,3 @@
1/* vi: set sw=4 ts=4: */
2/* 1/*
3 * Sysctl 1.01 - A utility to read and manipulate the sysctl parameters 2 * Sysctl 1.01 - A utility to read and manipulate the sysctl parameters
4 * 3 *
@@ -26,22 +25,8 @@ static const char ETC_SYSCTL_CONF[] ALIGN1 = "/etc/sysctl.conf";
26static const char PROC_SYS[] ALIGN1 = "/proc/sys/"; 25static const char PROC_SYS[] ALIGN1 = "/proc/sys/";
27enum { strlen_PROC_SYS = sizeof(PROC_SYS) - 1 }; 26enum { strlen_PROC_SYS = sizeof(PROC_SYS) - 1 };
28 27
29/* error messages */ 28static const char msg_unknown_key[] ALIGN1 =
30static const char ERR_MALFORMED_SETTING[] ALIGN1 =
31 "error: malformed setting '%s'";
32static const char ERR_NO_EQUALS[] ALIGN1 =
33 "error: '%s' must be of the form name=value";
34static const char ERR_INVALID_KEY[] ALIGN1 =
35 "error: '%s' is an unknown key"; 29 "error: '%s' is an unknown key";
36static const char ERR_UNKNOWN_WRITING[] ALIGN1 =
37 "error setting key '%s'";
38static const char ERR_UNKNOWN_READING[] ALIGN1 =
39 "error reading key '%s'";
40static const char ERR_PERMISSION_DENIED[] ALIGN1 =
41 "error: permission denied on key '%s'";
42static const char WARN_BAD_LINE[] ALIGN1 =
43 "warning: %s(%d): invalid syntax, continuing";
44
45 30
46static void dwrite_str(int fd, const char *buf) 31static void dwrite_str(int fd, const char *buf)
47{ 32{
@@ -98,7 +83,8 @@ static int sysctl_preload_file_and_exit(const char *filename)
98 parser = config_open(filename); 83 parser = config_open(filename);
99 while (config_read(parser, token, 2, 2, "# \t=", PARSE_NORMAL)) { // TODO: ';' is comment char too 84 while (config_read(parser, token, 2, 2, "# \t=", PARSE_NORMAL)) { // TODO: ';' is comment char too
100// if (!token[1]) { 85// if (!token[1]) {
101// bb_error_msg(WARN_BAD_LINE, filename, parser->lineno); 86// bb_error_msg("warning: %s(%d): invalid syntax, continuing",
87// filename, parser->lineno);
102// } else { 88// } else {
103 { 89 {
104#if 0 90#if 0
@@ -131,13 +117,13 @@ static int sysctl_write_setting(const char *setting)
131 name = setting; 117 name = setting;
132 equals = strchr(setting, '='); 118 equals = strchr(setting, '=');
133 if (!equals) { 119 if (!equals) {
134 bb_error_msg(ERR_NO_EQUALS, setting); 120 bb_error_msg("error: '%s' must be of the form name=value", setting);
135 return EXIT_FAILURE; 121 return EXIT_FAILURE;
136 } 122 }
137 123
138 value = equals + 1; /* point to the value in name=value */ 124 value = equals + 1; /* point to the value in name=value */
139 if (name == equals || !*value) { 125 if (name == equals || !*value) {
140 bb_error_msg(ERR_MALFORMED_SETTING, setting); 126 bb_error_msg("error: malformed setting '%s'", setting);
141 return EXIT_FAILURE; 127 return EXIT_FAILURE;
142 } 128 }
143 129
@@ -154,13 +140,10 @@ static int sysctl_write_setting(const char *setting)
154 switch (errno) { 140 switch (errno) {
155 case ENOENT: 141 case ENOENT:
156 if (option_mask32 & FLAG_SHOW_KEY_ERRORS) 142 if (option_mask32 & FLAG_SHOW_KEY_ERRORS)
157 bb_error_msg(ERR_INVALID_KEY, outname); 143 bb_error_msg(msg_unknown_key, outname);
158 break;
159 case EACCES:
160 bb_perror_msg(ERR_PERMISSION_DENIED, outname);
161 break; 144 break;
162 default: 145 default:
163 bb_perror_msg(ERR_UNKNOWN_WRITING, outname); 146 bb_perror_msg("error setting key '%s'", outname);
164 break; 147 break;
165 } 148 }
166 retval = EXIT_FAILURE; 149 retval = EXIT_FAILURE;
@@ -191,7 +174,7 @@ static int sysctl_read_setting(const char *name)
191 174
192 if (!*name) { 175 if (!*name) {
193 if (option_mask32 & FLAG_SHOW_KEY_ERRORS) 176 if (option_mask32 & FLAG_SHOW_KEY_ERRORS)
194 bb_error_msg(ERR_INVALID_KEY, name); 177 bb_error_msg(msg_unknown_key, name);
195 return -1; 178 return -1;
196 } 179 }
197 180
@@ -208,13 +191,10 @@ static int sysctl_read_setting(const char *name)
208 switch (errno) { 191 switch (errno) {
209 case ENOENT: 192 case ENOENT:
210 if (option_mask32 & FLAG_SHOW_KEY_ERRORS) 193 if (option_mask32 & FLAG_SHOW_KEY_ERRORS)
211 bb_error_msg(ERR_INVALID_KEY, outname); 194 bb_error_msg(msg_unknown_key, outname);
212 break;
213 case EACCES:
214 bb_error_msg(ERR_PERMISSION_DENIED, outname);
215 break; 195 break;
216 default: 196 default:
217 bb_perror_msg(ERR_UNKNOWN_READING, outname); 197 bb_perror_msg("error reading key '%s'", outname);
218 break; 198 break;
219 } 199 }
220 retval = EXIT_FAILURE; 200 retval = EXIT_FAILURE;