X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fmain.c;h=aa0e9bcdcc6d7206bd71d80101ba56e205ae7a48;hb=61354a55ac2abd9e83e1f869cdb735654d6eb74a;hp=89b7023f6ea63d9a64ba387a10c795cbec89cef2;hpb=e7c246a1b0d30b8156c7033061a61ecb5d2bdfc8;p=src%2Fapp-framework-binder.git diff --git a/src/main.c b/src/main.c index 89b7023f..aa0e9bcd 100644 --- a/src/main.c +++ b/src/main.c @@ -72,9 +72,10 @@ static sigjmp_buf exitPoint; // context save for set/longjmp #define SET_CONFIG_EXIT 138 #define SET_SMACK 140 - #define SET_PLUGINS 141 - #define SET_APITIMEOUT 142 - #define SET_CNTXTIMEOUT 143 + #define SET_AUTH_TOKEN 141 + #define SET_PLUGINS 142 + #define SET_APITIMEOUT 143 + #define SET_CNTXTIMEOUT 144 #define DISPLAY_VERSION 150 #define DISPLAY_HELP 151 @@ -108,6 +109,7 @@ static AFB_options cliOptions [] = { {SET_SMACK ,1,"smack" , "Set Smack Label [default demo]"}, {SET_PLUGINS ,1,"mods" , "Enable module [default all]"}, + {SET_AUTH_TOKEN ,1,"token" , "Initial Secret [default=no-session, --token="" for session without authentication]"}, {DISPLAY_VERSION ,0,"version" , "Display version and copyright"}, {DISPLAY_HELP ,0,"help" , "Display this help"}, @@ -157,7 +159,7 @@ void signalQuit (int signum) { fprintf (stderr," --%-15s %s\n", command, cliOptions[ind].help); } } - fprintf (stderr,"Example:\n %s\\\n --verbose --port=1234 --smack=xxxx --mods=alsa:dbus\n", name); + fprintf (stderr,"Example:\n %s\\\n --verbose --port=1234 --smack=xxxx --token='azerty' --mods=alsa:dbus\n", name); } // end printHelp /*---------------------------------------------------------- @@ -244,7 +246,7 @@ static void listenLoop (AFB_session *session) { fprintf (stderr, "hoops returned from infinite loop [report bug]\n"); } } - + /*--------------------------------------------------------- | main | Parse option and launch action @@ -348,6 +350,11 @@ int main(int argc, char *argv[]) { cliconfig.smack = optarg; break; + case SET_AUTH_TOKEN: + if (optarg == 0) goto needValueForOption; + cliconfig.token = optarg; + break; + case SET_PLUGINS: if (optarg == 0) goto needValueForOption; fprintf (stderr, "Not Implemented yet\n"); @@ -427,11 +434,10 @@ int main(int argc, char *argv[]) { } } - // Create session config - configInit (/* session & config are initialized globally */); - + // if exist merge config file with CLI arguments configLoadFile (session, &cliconfig); + initPlugins(session); // ------------------ sanity check ---------------------------------------- if ((session->background) && (session->foreground)) { @@ -504,7 +510,7 @@ int main(int argc, char *argv[]) { } // let's not take the risk to run as ROOT - if (getuid() == 0) goto errorNoRoot; + //if (getuid() == 0) goto errorNoRoot; // check session dir and create if it does not exist if (sessionCheckdir (session) != AFB_SUCCESS) goto errSessiondir; @@ -591,9 +597,9 @@ errorSetuid: fprintf (stderr,"\nERR:AFB-daemon Failed to change UID to username=[%s]\n\n", session->config->setuid); exit (-1); -errorNoRoot: - fprintf (stderr,"\nERR:AFB-daemon Not allow to run as root [use --seteuid=username option]\n\n"); - exit (-1); +//errorNoRoot: +// fprintf (stderr,"\nERR:AFB-daemon Not allow to run as root [use --seteuid=username option]\n\n"); +// exit (-1); errorPidFile: fprintf (stderr,"\nERR:AFB-daemon Failed to write pid file [%s]\n\n", session->config->pidfile);