commit 48488136e0d5972cad38e3192ae5a615731bb97f from: Stefan Sperling via: Thomas Adam date: Sat Apr 22 18:09:16 2023 UTC remove dependency of gitwrapper on gotd/auth.c Move gotd_auth_parseuid() from auth.c to parse.y as gotd_parseuid(), and remove auth.c from the list of source files required by gitwrapper. commit - 65a36f170d3f7b1ba00e709925d6a320cbecef60 commit + 48488136e0d5972cad38e3192ae5a615731bb97f blob - 63098f02298c146e943e4011ce9ae7a50aa48d24 blob + de09563aef39f346f9cf2c078c8dff429dc7bc4a --- gitwrapper/Makefile +++ gitwrapper/Makefile @@ -9,7 +9,7 @@ BINDIR ?= ${PREFIX}/bin PROG= gitwrapper -SRCS= gitwrapper.c parse.y log.c dial.c path.c error.c auth.c \ +SRCS= gitwrapper.c parse.y log.c dial.c path.c error.c \ reference_parse.c hash.c object_parse.c imsg.c \ inflate.c pollfd.c blob - d74ab2f3a2865e540ecb51ffc8b273b3f0ebb8c1 blob + bd0826ccbd54e9e2d89f708043511316e97fde6c --- gotd/auth.c +++ gotd/auth.c @@ -68,25 +68,7 @@ auth_sighdlr(int sig, short event, void *arg) break; default: fatalx("unexpected signal"); - } -} - -int -gotd_auth_parseuid(const char *s, uid_t *uid) -{ - struct passwd *pw; - const char *errstr; - - if ((pw = getpwnam(s)) != NULL) { - *uid = pw->pw_uid; - if (*uid == UID_MAX) - return -1; - return 0; } - *uid = strtonum(s, 0, UID_MAX - 1, &errstr); - if (errstr) - return -1; - return 0; } static int @@ -94,7 +76,7 @@ uidcheck(const char *s, uid_t desired) { uid_t uid; - if (gotd_auth_parseuid(s, &uid) != 0) + if (gotd_parseuid(s, &uid) != 0) return -1; if (uid != desired) return -1; blob - 87cd12560d438c7e4b48d2f7a762ff678b51d92e blob + 0fcd934ebdefa26902bdcb8c2548b82a37a8c8a9 --- gotd/auth.h +++ gotd/auth.h @@ -14,6 +14,5 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -int gotd_auth_parseuid(const char *, uid_t *); void auth_main(const char *title, struct gotd_repolist *repos, const char *repo_path); blob - da5659310b289bac96cef1db5c87299064a62cc5 blob + b08623dd82c94711edc63cc23126b9a581a45c31 --- gotd/gotd.h +++ gotd/gotd.h @@ -454,6 +454,7 @@ struct gotd_repo *gotd_find_repo_by_name(const char *, struct gotd_repo *gotd_find_repo_by_path(const char *, struct gotd *); struct gotd_uid_connection_limit *gotd_find_uid_connection_limit( struct gotd_uid_connection_limit *limits, size_t nlimits, uid_t uid); +int gotd_parseuid(const char *s, uid_t *uid); /* imsg.c */ const struct got_error *gotd_imsg_flush(struct imsgbuf *); blob - 7c22e7b91c8d384d95968e9643bdac9c6069bc33 blob + 8ebf4b83dbc2a957e8463aa6ad76e0f721af95dd --- gotd/parse.y +++ gotd/parse.y @@ -33,6 +33,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -832,7 +835,7 @@ conf_limit_user_connections(const char *user, int maxi return -1; } - if (gotd_auth_parseuid(user, &uid) == -1) { + if (gotd_parseuid(user, &uid) == -1) { yyerror("%s: no such user", user); return -1; } @@ -1143,3 +1146,21 @@ gotd_find_uid_connection_limit(struct gotd_uid_connect return NULL; } + +int +gotd_parseuid(const char *s, uid_t *uid) +{ + struct passwd *pw; + const char *errstr; + + if ((pw = getpwnam(s)) != NULL) { + *uid = pw->pw_uid; + if (*uid == UID_MAX) + return -1; + return 0; + } + *uid = strtonum(s, 0, UID_MAX - 1, &errstr); + if (errstr) + return -1; + return 0; +}