fix crash if no uci config file present
[oweals/mountd.git] / main.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <sys/types.h>
6
7 #include "include/log.h"
8 #include "include/sys.h"
9 #include "include/timer.h"
10 #include "include/autofs.h"
11 #include "include/led.h"
12
13 int daemonize = 0;
14
15 int main(int argc, char *argv[])
16 {
17         if ((argc < 2) || strcmp(argv[1], "-f"))
18                 daemon(0,0);
19
20         daemonize = 1;
21         log_start();
22         log_printf("Starting OpenWrt (auto)mountd V1\n");
23         timer_init();
24         led_init(0);
25         if (geteuid() != 0) {
26                 fprintf(stderr, "This program must be run by root.\n");
27                 return 1;
28         }
29         return autofs_loop();
30 }