mirror of
https://github.com/troglobit/finit.git
synced 2026-10-29 12:40:44 +00:00
Move conffile parsing to proper function
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
1 parent
6ff7f2e52b
commit
c8e7b34b4c
2 files changed
+32
-22
No files matched your search
@@ -6,8 +6,8 @@ O.4 ()
|
|||||||
- handle pam_console permissions in finit-alt for Mandriva
|
- handle pam_console permissions in finit-alt for Mandriva
|
||||||
- add services.sh example and nash-hotplug patch for Mandriva
|
- add services.sh example and nash-hotplug patch for Mandriva
|
||||||
- mount /proc/bus/usb in Mandriva
|
- mount /proc/bus/usb in Mandriva
|
||||||
- finit-mdv checks filesystem if CHECKFS= parameter is specified
|
- add runtime debug to finit-alt if finit_debug parameter is specified
|
||||||
- add runtime debug to finit-alt if DEBUG parameter is specified
|
- red configuration from /etc/finit.conf
|
||||||
|
|
||||||
0.3 (20080223)
|
0.3 (20080223)
|
||||||
- Change poweroff method to reboot(RB_POWER_OFF) (Metalshark)
|
- Change poweroff method to reboot(RB_POWER_OFF) (Metalshark)
|
||||||
|
|||||||
+30
-20
@@ -83,12 +83,32 @@ THE SOFTWARE.
|
|||||||
#define chardev(x,m,maj,min) mknod((x), S_IFCHR|(m), makedev((maj),(min)))
|
#define chardev(x,m,maj,min) mknod((x), S_IFCHR|(m), makedev((maj),(min)))
|
||||||
#define blkdev(x,m,maj,min) mknod((x), S_IFBLK|(m), makedev((maj),(min)))
|
#define blkdev(x,m,maj,min) mknod((x), S_IFBLK|(m), makedev((maj),(min)))
|
||||||
|
|
||||||
|
#define MATCH_CMD(l,c,x) \
|
||||||
|
(((x) = strstr((l), (c))) == (l) && ((x) += strlen((c))))
|
||||||
|
|
||||||
#define LINE_SIZE 1024
|
#define LINE_SIZE 1024
|
||||||
|
#define CMD_SIZE 256
|
||||||
|
#define USERNAME_SIZE 16
|
||||||
|
|
||||||
void shutdown(int);
|
void shutdown(int);
|
||||||
void signal_handler(int);
|
void signal_handler(int);
|
||||||
void chld_handler(int);
|
void chld_handler(int);
|
||||||
|
|
||||||
|
static int debug = 0;
|
||||||
|
|
||||||
|
static void build_cmd(char *cmd, char *x, int len)
|
||||||
|
{
|
||||||
|
int l;
|
||||||
|
char *c;
|
||||||
|
|
||||||
|
c = cmd + strlen(cmd);
|
||||||
|
for (l = 0; x && *x && *x != ' ' && l < len; l++)
|
||||||
|
*c++ = *x++;
|
||||||
|
*c = 0;
|
||||||
|
if (debug)
|
||||||
|
printf("cmd = %s\n", cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -101,9 +121,8 @@ int main()
|
|||||||
struct sigaction sa, act;
|
struct sigaction sa, act;
|
||||||
char *x;
|
char *x;
|
||||||
sigset_t nmask, nmask2;
|
sigset_t nmask, nmask2;
|
||||||
int debug = 0;
|
char username[USERNAME_SIZE];
|
||||||
char username[16];
|
char cmd[CMD_SIZE];
|
||||||
char *c, cmd[256];
|
|
||||||
|
|
||||||
puts("finit-alt " VERSION " (built " __DATE__ " by " WHOAMI ")");
|
puts("finit-alt " VERSION " (built " __DATE__ " by " WHOAMI ")");
|
||||||
|
|
||||||
@@ -137,7 +156,6 @@ int main()
|
|||||||
|
|
||||||
mount("proc", "/proc", "proc", 0, NULL);
|
mount("proc", "/proc", "proc", 0, NULL);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse kernel parameters
|
* Parse kernel parameters
|
||||||
*/
|
*/
|
||||||
@@ -148,7 +166,7 @@ int main()
|
|||||||
close(1);
|
close(1);
|
||||||
close(2);
|
close(2);
|
||||||
}
|
}
|
||||||
if ((strstr(line, "DEBUG"))) {
|
if ((strstr(line, "finit_debug"))) {
|
||||||
debug = 1;
|
debug = 1;
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@@ -169,28 +187,20 @@ int main()
|
|||||||
if (debug)
|
if (debug)
|
||||||
printf("conf: %s\n", line);
|
printf("conf: %s\n", line);
|
||||||
|
|
||||||
if ((x = strstr(line, "check ")) == line) {
|
if (MATCH_CMD(line, "check ", x)) {
|
||||||
x += 6;
|
|
||||||
strcpy(cmd, "/sbin/e2fsck -C -p ");
|
strcpy(cmd, "/sbin/e2fsck -C -p ");
|
||||||
c = cmd + strlen(cmd);
|
build_cmd(cmd, x, CMD_SIZE);
|
||||||
while (x && *x && *x != ' ') *c++ = *x++;
|
|
||||||
*c = 0;
|
|
||||||
system(cmd);
|
system(cmd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((x = strstr(line, "user ")) == line) {
|
if (MATCH_CMD(line, "user ", x)) {
|
||||||
x += 5;
|
*username = 0;
|
||||||
c = username;
|
build_cmd(username, x, USERNAME_SIZE);
|
||||||
while (x && *x && *x != ' ') *c++ = *x++;
|
|
||||||
*c = 0;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((x = strstr(line, "module ")) == line) {
|
if (MATCH_CMD(line, "module ", x)) {
|
||||||
x += 7;
|
|
||||||
strcpy(cmd, "/sbin/modprobe ");
|
strcpy(cmd, "/sbin/modprobe ");
|
||||||
c = cmd + strlen(cmd);
|
build_cmd(cmd, x, CMD_SIZE);
|
||||||
while (x && *x && *x != ' ') *c++ = *x++;
|
|
||||||
*c = 0;
|
|
||||||
system(cmd);
|
system(cmd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user