From fa6a85c147ba0f45d697b2e6bde9039c3b0d4c98 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Dutta <vivek.dutta@iopsys.eu> Date: Mon, 28 Apr 2025 19:09:36 +0530 Subject: [PATCH] Remove RemoteAccessCapable and updated logging --- src/main.c | 31 ++++++++++++++++++++++++++++++- src/users.c | 23 ----------------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/main.c b/src/main.c index e1b1dcf..51e54a2 100644 --- a/src/main.c +++ b/src/main.c @@ -247,8 +247,37 @@ static int register_config_change(struct ubus_context *uctx) return 0; } +static void usage(const char *prog) +{ + fprintf(stderr, "Usage: %s [options]\n", prog); + fprintf(stderr, "\n"); + fprintf(stderr, "options:\n"); + fprintf(stderr, " -l <0-7> Set the loglevel\n"); + fprintf(stderr, " -h Displays this help\n"); + fprintf(stderr, "\n"); +} + int main(int argc, char **argv) { + int log_level = 7; + int c = 0; + + while ((c = getopt(argc, argv, "hl:")) != -1) { + switch (c) { + case 'l': + log_level = (int)strtod(optarg, NULL); + if (log_level < 0 || log_level > 7) { + log_level = 7; + } + break; + case 'h': + usage(argv[0]); + exit(0); + default: + usage(argv[0]); + exit(0); + } + } load_system_users(); load_system_groups(); @@ -258,7 +287,7 @@ int main(int argc, char **argv) create_users(); bbfdm_ubus_set_service_name(&bbfdm_ctx, "usermngr"); - bbfdm_ubus_set_log_level(3); + bbfdm_ubus_set_log_level(log_level); bbfdm_ubus_load_data_model(tDynamicObj); if (bbfdm_ubus_regiter_init(&bbfdm_ctx)) diff --git a/src/users.c b/src/users.c index af4b7e6..4d96006 100644 --- a/src/users.c +++ b/src/users.c @@ -810,12 +810,6 @@ static int get_user_password(char *refparam, struct dmctx *ctx, void *data, char return 0; } -static int get_user_remote_accessable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = bbf_uci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "remote_access", "1"); - return 0; -} - static int get_user_group_participation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *groups = NULL; @@ -1165,22 +1159,6 @@ static int set_user_password(char *refparam, struct dmctx *ctx, void *data, char return 0; } -static int set_user_remote_accessable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - bool b; - switch (action) { - case VALUECHECK: - if (bbfdm_validate_boolean(ctx, value)) - return FAULT_9007; - break; - case VALUESET: - bbf_convert_string_to_bool(value, &b); - bbf_uci_set_value_by_section(((struct dm_data *)data)->config_section, "remote_access", b ? "1" : "0"); - break; - } - return 0; -} - static int set_user_group_participation(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { struct dm_reference reference = {0}; @@ -1425,7 +1403,6 @@ DMLEAF tUsersUserParams[] = { {"UserID", &DMREAD, DMT_UNINT, get_user_id, NULL, BBFDM_BOTH, DM_FLAG_UNIQUE}, {"Username", &DMWRITE, DMT_STRING, get_param_name, set_user_username, BBFDM_BOTH, DM_FLAG_UNIQUE}, {"Password", &DMWRITE, DMT_STRING, get_user_password, set_user_password, BBFDM_BOTH, DM_FLAG_SECURE}, -{"RemoteAccessCapable", &DMWRITE, DMT_BOOL, get_user_remote_accessable, set_user_remote_accessable, BBFDM_BOTH}, {"GroupParticipation", &DMWRITE, DMT_STRING, get_user_group_participation, set_user_group_participation, BBFDM_BOTH, DM_FLAG_REFERENCE}, {"RoleParticipation", &DMWRITE, DMT_STRING, get_role_participation, set_role_participation, BBFDM_BOTH, DM_FLAG_REFERENCE}, {"StaticUser", &DMREAD, DMT_BOOL, get_user_static_user, NULL, BBFDM_BOTH}, -- GitLab