summaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-21 23:05:26 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-21 23:05:26 +0000
commit5415c856eaccd1bc5d064022770a288f43b2e94f (patch)
tree5973db4e6f81b5e311e8944700ded5db1083d440 /loginutils
parentb74a2dba571d1c5a6127c683fb50923336d9c59f (diff)
downloadbusybox-w32-5415c856eaccd1bc5d064022770a288f43b2e94f.tar.gz
busybox-w32-5415c856eaccd1bc5d064022770a288f43b2e94f.tar.bz2
busybox-w32-5415c856eaccd1bc5d064022770a288f43b2e94f.zip
libbb: [x]fopen_for_{read,write} introduced and used.
(by Valdimir) function old new delta config_open2 - 41 +41 config_read 507 542 +35 find_pair 169 187 +18 fopen_for_write - 14 +14 fopen_for_read - 14 +14 find_main 406 418 +12 xfopen_for_write - 10 +10 xfopen_for_read - 10 +10 popstring 134 140 +6 parse_inittab 396 401 +5 next_token 923 928 +5 pack_gzip 1659 1661 +2 bb__parsespent 117 119 +2 fallbackSort 1719 1717 -2 evalvar 1376 1374 -2 qrealloc 36 33 -3 ... ... ... ... singlemount 4579 4569 -10 process_stdin 443 433 -10 patch_main 1111 1101 -10 ifupdown_main 2175 2165 -10 file_action_grep 90 80 -10 uuidcache_init 649 637 -12 hush_main 797 785 -12 read_config 230 217 -13 dpkg_main 3835 3820 -15 read_line_input 3134 3110 -24 sysctl_main 232 203 -29 config_open 40 10 -30 WARN_BAD_LINE 44 - -44 login_main 1714 1575 -139 ------------------------------------------------------------------------------ (add/remove: 5/1 grow/shrink: 8/74 up/down: 174/-737) Total: -563 bytes
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/getty.c2
-rw-r--r--loginutils/login.c34
2 files changed, 13 insertions, 23 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 7d4fe4df9..358a45c7c 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -668,7 +668,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
668 logmode = LOGMODE_BOTH; 668 logmode = LOGMODE_BOTH;
669 669
670#ifdef DEBUGGING 670#ifdef DEBUGGING
671 dbf = xfopen(DEBUGTERM, "w"); 671 dbf = xfopen_for_write(DEBUGTERM);
672 for (n = 1; argv[n]; n++) { 672 for (n = 1; argv[n]; n++) {
673 debug(argv[n]); 673 debug(argv[n]);
674 debug("\n"); 674 debug("\n");
diff --git a/loginutils/login.c b/loginutils/login.c
index 9c7941e0d..5a75ed218 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -122,7 +122,7 @@ static void die_if_nologin(void)
122 if (access("/etc/nologin", F_OK)) 122 if (access("/etc/nologin", F_OK))
123 return; 123 return;
124 124
125 fp = fopen("/etc/nologin", "r"); 125 fp = fopen_for_read("/etc/nologin");
126 if (fp) { 126 if (fp) {
127 while ((c = getc(fp)) != EOF) 127 while ((c = getc(fp)) != EOF)
128 bb_putchar((c=='\n') ? '\r' : c); 128 bb_putchar((c=='\n') ? '\r' : c);
@@ -139,30 +139,20 @@ static ALWAYS_INLINE void die_if_nologin(void) {}
139#if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM 139#if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM
140static int check_securetty(void) 140static int check_securetty(void)
141{ 141{
142 FILE *fp; 142 char *buf;
143 int i; 143 int ret = 1;
144 char buf[256]; 144 parser_t *parser = config_open2("/etc/securetty", fopen_for_read);
145 145 /* N.B. A missing securetty file is not an error. */
146 fp = fopen("/etc/securetty", "r"); 146 if (parser) {
147 if (!fp) { 147 while (config_read(parser, &buf, 1, 1, "# \t", 0)) {
148 /* A missing securetty file is not an error. */ 148 if (strcmp(buf, short_tty) == 0)
149 return 1;
150 }
151 while (fgets(buf, sizeof(buf)-1, fp)) {
152 for (i = strlen(buf)-1; i >= 0; --i) {
153 if (!isspace(buf[i]))
154 break; 149 break;
155 } 150 }
156 buf[++i] = '\0'; 151 config_close(parser);
157 if (!buf[0] || (buf[0] == '#')) 152 // buf != NULL here iff config file was empty (OK) or buf equals short_tty (OK)
158 continue; 153 ret = buf != NULL;
159 if (strcmp(buf, short_tty) == 0) {
160 fclose(fp);
161 return 1;
162 }
163 } 154 }
164 fclose(fp); 155 return ret;
165 return 0;
166} 156}
167#else 157#else
168static ALWAYS_INLINE int check_securetty(void) { return 1; } 158static ALWAYS_INLINE int check_securetty(void) { return 1; }