aboutsummaryrefslogtreecommitdiff
path: root/selinux
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-20 17:48:59 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-20 17:48:59 +0000
commita34f1ed737e79e494904706e59f4e7fbb49e32b3 (patch)
tree9c84f928e785775d99163b7de5c29e6f85a0fc8c /selinux
parent1e8034e61432cb3bd4bde1d7a13e809543a1e239 (diff)
downloadbusybox-w32-a34f1ed737e79e494904706e59f4e7fbb49e32b3.tar.gz
busybox-w32-a34f1ed737e79e494904706e59f4e7fbb49e32b3.tar.bz2
busybox-w32-a34f1ed737e79e494904706e59f4e7fbb49e32b3.zip
dnsd,sestatus: use libbb to parse config file (by Vladimir)
function old new delta dnsd_main 1544 1487 -57
Diffstat (limited to 'selinux')
-rw-r--r--selinux/sestatus.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/selinux/sestatus.c b/selinux/sestatus.c
index 3b027eeb2..1351600c8 100644
--- a/selinux/sestatus.c
+++ b/selinux/sestatus.c
@@ -47,31 +47,17 @@ static void display_boolean(void)
47 47
48static void read_config(char **pc, int npc, char **fc, int nfc) 48static void read_config(char **pc, int npc, char **fc, int nfc)
49{ 49{
50 char buf[256]; 50 char *buf;
51 FILE *fp; 51 parser_t *parser;
52 int pc_ofs = 0, fc_ofs = 0, section = -1; 52 int pc_ofs = 0, fc_ofs = 0, section = -1;
53 53
54 pc[0] = fc[0] = NULL; 54 pc[0] = fc[0] = NULL;
55 55
56 fp = fopen("/etc/sestatus.conf", "rb"); 56 parser = config_open("/etc/sestatus.conf");
57 if (fp == NULL) 57 if (!parser)
58 return; 58 return;
59 59
60 while (fgets(buf, sizeof(buf), fp) != NULL) { 60 while (config_read(parser, &buf, 1, 1, "# \t", PARSE_LAST_IS_GREEDY)) {
61 int i, c;
62
63 /* kills comments */
64 for (i = 0; (c = buf[i]) != '\0'; i++) {
65 if (c == '#') {
66 buf[i] = '\0';
67 break;
68 }
69 }
70 trim(buf);
71
72 if (buf[0] == '\0')
73 continue;
74
75 if (strcmp(buf, "[process]") == 0) { 61 if (strcmp(buf, "[process]") == 0) {
76 section = 1; 62 section = 1;
77 } else if (strcmp(buf, "[files]") == 0) { 63 } else if (strcmp(buf, "[files]") == 0) {
@@ -86,7 +72,7 @@ static void read_config(char **pc, int npc, char **fc, int nfc)
86 } 72 }
87 } 73 }
88 } 74 }
89 fclose(fp); 75 config_close(parser);
90} 76}
91 77
92static void display_verbose(void) 78static void display_verbose(void)