mirror of
https://github.com/haiwen/ccnet-server.git
synced 2025-09-02 13:25:03 +00:00
@@ -98,11 +98,12 @@ on_ccnet_exit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *short_options = "hvdtc:D:f:P:M:F:";
|
static const char *short_options = "hvdta:c:D:f:P:M:F:";
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{ "help", no_argument, NULL, 'h', },
|
{ "help", no_argument, NULL, 'h', },
|
||||||
{ "version", no_argument, NULL, 'v', },
|
{ "version", no_argument, NULL, 'v', },
|
||||||
{ "config-dir", required_argument, NULL, 'c' },
|
{ "config-dir", required_argument, NULL, 'c' },
|
||||||
|
{ "add-admin", required_argument, NULL, 'a' },
|
||||||
{ "central-config-dir", required_argument, NULL, 'F' },
|
{ "central-config-dir", required_argument, NULL, 'F' },
|
||||||
{ "logfile", required_argument, NULL, 'f' },
|
{ "logfile", required_argument, NULL, 'f' },
|
||||||
{ "debug", required_argument, NULL, 'D' },
|
{ "debug", required_argument, NULL, 'D' },
|
||||||
@@ -180,6 +181,7 @@ main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
char *config_dir;
|
char *config_dir;
|
||||||
|
char *admin_passwd = NULL;
|
||||||
char *central_config_dir = NULL;
|
char *central_config_dir = NULL;
|
||||||
char *log_file = 0;
|
char *log_file = 0;
|
||||||
const char *debug_str = 0;
|
const char *debug_str = 0;
|
||||||
@@ -227,6 +229,9 @@ main (int argc, char **argv)
|
|||||||
case 't':
|
case 't':
|
||||||
test_config = TRUE;
|
test_config = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case 'a':
|
||||||
|
admin_passwd = optarg;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "unknown option \"-%c\"\n", (char)c);
|
fprintf (stderr, "unknown option \"-%c\"\n", (char)c);
|
||||||
usage();
|
usage();
|
||||||
@@ -315,6 +320,29 @@ main (int argc, char **argv)
|
|||||||
"see log file for the detail.\n", stderr);
|
"see log file for the detail.\n", stderr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (admin_passwd) {
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
char **admin_pass = g_strsplit(admin_passwd, "/", 2);
|
||||||
|
|
||||||
|
if (g_strv_length (admin_pass) < 2 ) {
|
||||||
|
fprintf (stderr, "Error: Missing parameter, failed to add admin\n");
|
||||||
|
ret = -1;
|
||||||
|
} else if (!strcmp(admin_pass[0], "") || !strcmp(admin_pass[1], "")) {
|
||||||
|
fprintf (stderr, "Error: Username or password can't be null, failed to add admin\n");
|
||||||
|
ret = -1;
|
||||||
|
} else if (ccnet_user_manager_add_emailuser (((struct CcnetServerSession *)session)->user_mgr,
|
||||||
|
admin_pass[0],
|
||||||
|
admin_pass[1],
|
||||||
|
1, 1)) {
|
||||||
|
|
||||||
|
fprintf (stderr, "Error: Failed to add admin\n");
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_strfreev (admin_pass);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* write pidfile after session_prepare success, if there is
|
/* write pidfile after session_prepare success, if there is
|
||||||
* another instance of ccnet session_prepare will failed.
|
* another instance of ccnet session_prepare will failed.
|
||||||
|
Reference in New Issue
Block a user