diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-30 16:41:15 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-30 16:41:15 +0000 |
commit | 611f3bd96a89fbb13e082913d263849da4d18488 (patch) | |
tree | 2646cfd66b5a8d279ad360aaa989a814eeecfd64 /libbb | |
parent | 2e289b23747dc06d3701ca019380c0253f215cfe (diff) | |
download | busybox-w32-611f3bd96a89fbb13e082913d263849da4d18488.tar.gz busybox-w32-611f3bd96a89fbb13e082913d263849da4d18488.tar.bz2 busybox-w32-611f3bd96a89fbb13e082913d263849da4d18488.zip |
passwd: rework:
* do not make backup copy by copying (just retain old file)
* correctly fall back to /etc/passwd if user is not in shadow
* fix bug with overlong passwd entries
* be permissive on some kinds of failures
* reduce stack usage
* code size: -500 bytes
git-svn-id: svn://busybox.net/trunk/busybox@16739 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/bb_askpass.c | 2 | ||||
-rw-r--r-- | libbb/get_line_from_file.c | 14 | ||||
-rw-r--r-- | libbb/obscure.c | 10 |
3 files changed, 13 insertions, 13 deletions
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c index cf384e52b..097a0a290 100644 --- a/libbb/bb_askpass.c +++ b/libbb/bb_askpass.c | |||
@@ -60,7 +60,7 @@ char *bb_askpass(int timeout, const char * prompt) | |||
60 | (read did not overwrite it) */ | 60 | (read did not overwrite it) */ |
61 | do { | 61 | do { |
62 | if (passwd[i] == '\r' || passwd[i] == '\n') | 62 | if (passwd[i] == '\r' || passwd[i] == '\n') |
63 | passwd[i] = 0; | 63 | passwd[i] = '\0'; |
64 | } while (passwd[i++]); | 64 | } while (passwd[i++]); |
65 | } | 65 | } |
66 | 66 | ||
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index 969d808cf..b424d59e9 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c | |||
@@ -9,11 +9,9 @@ | |||
9 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 9 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <stdio.h> | ||
13 | #include <stdlib.h> | ||
14 | #include "libbb.h" | 12 | #include "libbb.h" |
15 | 13 | ||
16 | /* get_line_from_file() - This function reads an entire line from a text file, | 14 | /* This function reads an entire line from a text file, |
17 | * up to a newline or NUL byte. It returns a malloc'ed char * which must be | 15 | * up to a newline or NUL byte. It returns a malloc'ed char * which must be |
18 | * stored and free'ed by the caller. If end is null '\n' isn't considered | 16 | * stored and free'ed by the caller. If end is null '\n' isn't considered |
19 | * end of line. If end isn't null, length of the chunk read is stored in it. */ | 17 | * end of line. If end isn't null, length of the chunk read is stored in it. */ |
@@ -37,10 +35,12 @@ char *bb_get_chunk_from_file(FILE * file, int *end) | |||
37 | if (end) | 35 | if (end) |
38 | *end = idx; | 36 | *end = idx; |
39 | if (linebuf) { | 37 | if (linebuf) { |
40 | if (ferror(file)) { | 38 | // huh, is fgets discards prior data on error like this? |
41 | free(linebuf); | 39 | // I don't think so.... |
42 | return NULL; | 40 | //if (ferror(file)) { |
43 | } | 41 | // free(linebuf); |
42 | // return NULL; | ||
43 | //} | ||
44 | linebuf = xrealloc(linebuf, idx+1); | 44 | linebuf = xrealloc(linebuf, idx+1); |
45 | linebuf[idx] = 0; | 45 | linebuf[idx] = 0; |
46 | } | 46 | } |
diff --git a/libbb/obscure.c b/libbb/obscure.c index 7d839d624..2599095df 100644 --- a/libbb/obscure.c +++ b/libbb/obscure.c | |||
@@ -157,14 +157,14 @@ static const char *obscure_msg(const char *old_p, const char *new_p, const struc | |||
157 | return NULL; | 157 | return NULL; |
158 | } | 158 | } |
159 | 159 | ||
160 | int obscure(const char *old, const char *newval, const struct passwd *pwdp) | 160 | int obscure(const char *old, const char *newval, const struct passwd *pw) |
161 | { | 161 | { |
162 | const char *msg; | 162 | const char *msg; |
163 | 163 | ||
164 | if ((msg = obscure_msg(old, newval, pwdp))) { | 164 | msg = obscure_msg(old, newval, pw); |
165 | printf("Bad password: %s.\n", msg); | 165 | if (msg) { |
166 | /* If user is root warn only */ | 166 | printf("Bad password: %s\n", msg); |
167 | return getuid() ? 1 : 0; | 167 | return 1; |
168 | } | 168 | } |
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |