summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-12-12 15:57:47 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-12-12 16:05:55 +0100
commit5e21716afba461a4debae8f99f0e6e967766bb28 (patch)
treee255c3b0783d61f3586922d6411a335b5b9495cd /src
parent6a63218f85d80919c8bab87141f9f4c9c3acdfdf (diff)
cfg: add samba configuration and use it in ogrelive templatev1.2.5-28
add samba credentials to ogserver.json "samba" : { "user" : "og", "pass" : "test" } and use it in ogrelive template.
Diffstat (limited to 'src')
-rw-r--r--src/cfg.c31
-rw-r--r--src/cfg.h4
-rw-r--r--src/rest.c4
3 files changed, 37 insertions, 2 deletions
diff --git a/src/cfg.c b/src/cfg.c
index c4a252f..1b81a91 100644
--- a/src/cfg.c
+++ b/src/cfg.c
@@ -70,6 +70,27 @@ static int parse_json_db(struct og_server_cfg *cfg, json_t *element)
return 0;
}
+static int parse_json_samba(struct og_server_cfg *cfg, json_t *element)
+{
+ const char *key;
+ json_t *value;
+
+ json_object_foreach(element, key, value) {
+ if (!strcmp(key, "user")) {
+ if (og_json_parse_string(value, &cfg->smb.user) < 0)
+ return -1;
+ } else if (!strcmp(key, "pass")) {
+ if (og_json_parse_string(value, &cfg->smb.pass) < 0)
+ return -1;
+ } else {
+ syslog(LOG_ERR, "unknown key `%s' in samba\n", key);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
static int parse_json_wol(struct og_server_cfg *cfg, json_t *element)
{
const char *key;
@@ -110,6 +131,7 @@ static int parse_json_repo(struct og_server_cfg *cfg, json_t *element)
#define OG_SERVER_CFG_DB (1 << 1)
#define OG_SERVER_CFG_WOL (1 << 2)
#define OG_SERVER_CFG_REPO (1 << 3)
+#define OG_SERVER_CFG_SAMBA (1 << 4)
int parse_json_config(const char *filename, struct og_server_cfg *cfg)
{
@@ -157,6 +179,12 @@ int parse_json_config(const char *filename, struct og_server_cfg *cfg)
break;
}
flags |= OG_SERVER_CFG_DB;
+ } else if (!strcmp(key, "samba")) {
+ if (parse_json_samba(cfg, value) < 0) {
+ ret = -1;
+ break;
+ }
+ flags |= OG_SERVER_CFG_SAMBA;
} else if (!strcmp(key, "repository")) {
if (parse_json_repo(cfg, value) < 0)
return -1;
@@ -181,6 +209,9 @@ int parse_json_config(const char *filename, struct og_server_cfg *cfg)
ret = -1;
}
+ if (!(flags & OG_SERVER_CFG_SAMBA))
+ syslog(LOG_WARNING, "Missing samba configuration in ogserver.json file");
+
if (ret < 0)
json_decref(root);
else
diff --git a/src/cfg.h b/src/cfg.h
index 97e47cf..d65782c 100644
--- a/src/cfg.h
+++ b/src/cfg.h
@@ -12,6 +12,10 @@ struct og_server_cfg {
const char *api_token;
} rest;
struct {
+ const char *user;
+ const char *pass;
+ } smb;
+ struct {
const char *interface;
} wol;
struct {
diff --git a/src/rest.c b/src/rest.c
index d2ca050..17878b0 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -1724,8 +1724,8 @@ static int og_set_client_mode(struct og_dbi *dbi, const char *client_ip,
boot_cfg.ogserver = boot_params.server_ip;
boot_cfg.ogrepo = boot_params.repo_ip;
boot_cfg.ogrelivedir = boot_params.oglivedir;
- boot_cfg.username = "opengnsys";
- boot_cfg.passwd = ogconfig.db.pass;
+ boot_cfg.username = ogconfig.smb.user;
+ boot_cfg.passwd = ogconfig.smb.pass;
if (ogrelive_generate_grub2_file(&boot_cfg, mac) < 0) {
syslog(LOG_ERR, "failed to create HTTP boot file (%s:%d)\n", __FILE__, __LINE__);