summaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2025-04-11 09:54:40 -0700
committerGravatar Anshul Gupta <ansg191@anshulg.com> 2025-04-11 09:54:40 -0700
commitc1cf314f7844b91ff1e1204fd4b1e6edcddb8554 (patch)
tree95a262a730e509b092c8a78d840d885e71d573bc /src/config.c
parentf277f41d83d450a1f28d350bb7d6da075d1d2741 (diff)
downloadgithub-mirror-c1cf314f7844b91ff1e1204fd4b1e6edcddb8554.tar.gz
github-mirror-c1cf314f7844b91ff1e1204fd4b1e6edcddb8554.tar.zst
github-mirror-c1cf314f7844b91ff1e1204fd4b1e6edcddb8554.zip
Drop root requirement (and libcap dependency)
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c51
1 files changed, 6 insertions, 45 deletions
diff --git a/src/config.c b/src/config.c
index d20f4f5..7f610a6 100644
--- a/src/config.c
+++ b/src/config.c
@@ -7,7 +7,6 @@
#include <ctype.h>
#include <fcntl.h>
#include <grp.h>
-#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -16,11 +15,11 @@
#include <unistd.h>
const char *config_locations[] = {
- "/etc/github_mirror/config.ini",
- "/usr/local/etc/github_mirror/config.ini",
- "/usr/local/github_mirror/config.ini",
- "config.ini",
- NULL,
+ "/etc/github_mirror/config.ini",
+ "/usr/local/etc/github_mirror/config.ini",
+ "/usr/local/github_mirror/config.ini",
+ "config.ini",
+ NULL,
};
enum config_section {
@@ -84,10 +83,6 @@ static char *trim(char *start, char *end)
static int parse_line_inner(struct config *cfg, enum config_section section,
char *key, char *value)
{
- char *endptr;
- struct passwd *pw;
- struct group *gr;
-
switch (section) {
case section_none:
fprintf(stderr,
@@ -113,39 +108,7 @@ static int parse_line_inner(struct config *cfg, enum config_section section,
case section_git:
if (!strcmp(key, "base"))
cfg->git_base = value;
- else if (!strcmp(key, "owner")) {
- // If the value is a number, set the owner to that
- // number
- cfg->git_owner = strtol(value, &endptr, 10);
- if (*endptr == '\0')
- return 0;
-
- // Otherwise, convert the string into a uid
- if (!((pw = getpwnam(value)))) {
- fprintf(stderr,
- "Error parsing config file: unknown "
- "user: %s\n",
- value);
- return -1;
- }
- cfg->git_owner = pw->pw_uid;
- } else if (!strcmp(key, "group")) {
- // If the value is a number, set the group to that
- // number
- cfg->git_group = strtol(value, &endptr, 10);
- if (*endptr == '\0')
- return 0;
-
- // Otherwise, convert the string into a gid
- if (!((gr = getgrnam(value)))) {
- fprintf(stderr,
- "Error parsing config file: unknown "
- "group: %s\n",
- value);
- return -1;
- }
- cfg->git_group = gr->gr_gid;
- } else {
+ else {
fprintf(stderr,
"Error parsing config file: unknown key: %s\n",
key);
@@ -247,8 +210,6 @@ static void config_defaults(struct config *cfg)
cfg->endpoint = GH_DEFAULT_ENDPOINT;
cfg->user_agent = GH_DEFAULT_USER_AGENT;
cfg->git_base = "/srv/git";
- cfg->git_owner = getuid();
- cfg->git_group = getgid();
}
static int config_validate(const struct config *cfg)