commit c381a9c462498f67f93338e33ae530dd95b57dbd3e40e4aede7d89db0e5edb52 from: Stefan Sperling date: Mon Apr 13 10:14:16 2026 UTC make gotwebd display logged-in usernames in case of group-membership auth In cases where the access identifier is a group name, gotwebd would display a group name rather than the name of the authenticated user in the "Logged in as" banner. We always want to display the user name. review/ok runxiyu commit - de3ada86e34282186fb0fffb169c74e4cca0216f9bbb1d053aa78c440c94c36c commit + c381a9c462498f67f93338e33ae530dd95b57dbd3e40e4aede7d89db0e5edb52 blob - a4661acb08b133c3f72fc9349bfae1e9fcd8f8a23158eac7bb5d983023bca5fb blob + 156a3f313fc90a6df2aac13a704945f76eadec7ba8ee43b7320ba28603a58236 --- gotwebd/auth.c +++ gotwebd/auth.c @@ -521,6 +521,7 @@ process_request(struct request *c) const char *identifier = NULL; char *request_path = NULL; int is_repository_request = 0; + struct passwd *pw = NULL; srv = gotweb_get_server(c->fcgi_params.server_name); if (srv == NULL) { @@ -688,6 +689,15 @@ permitted: "identifier too long"); goto done; } + pw = getpwuid(uid); + if (pw) { + if (strlcpy(c->client_username, pw->pw_name, + sizeof(c->client_username)) >= sizeof(c->client_username)) { + error = got_error_msg(GOT_ERR_NO_SPACE, + "username too long"); + goto done; + } + } if (gotwebd_env->gotwebd_verbose > 0) { log_info("authenticated UID %u as %s for server \"%s\"", blob - 0d93057916fb19a5e672b41593c08242564928944be48a241fb7b2d5cf3b5503 blob + c847e0c272361c2cad1c16a4790eddd58a58db761cf1bc1621ccd266d3368ee5 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -353,6 +353,7 @@ struct request { uid_t client_uid; char access_identifier[MAX_IDENTIFIER_SIZE]; + char client_username[MAX_IDENTIFIER_SIZE]; }; TAILQ_HEAD(requestlist, request); blob - e846dcf1482320b60b370e4e77978e7bf13606cfda3743f6046aae45e099e67a blob + 2021ad223878857aef27e1b8ae89f5b4b0c870d5a9bdfb0e0197f62a8c24e0bd --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -226,9 +226,10 @@ nextsep(char *s, char **t) - {{ if (c->access_identifier[0]) }} + {{ if (c->client_username[0] || c->access_identifier[0]) }}
- Logged in as: {{ c->access_identifier }}   + Logged in as: {{ c->client_username[0] ? + c->client_username : c->access_identifier }}   (Logout)
{{ end }} blob - b6bf90d0f30abc3ab290ba8c0f79c10d0ede37d3c61b14c2dd9e98e53ff43df3 blob + 5269911176f549d7dace31847685d10735427f9286fac6df40b1889d6f71d5ef --- regress/gotsysd/test_gotwebd.sh +++ regress/gotsysd/test_gotwebd.sh @@ -738,7 +738,151 @@ EOF return 1 fi + # Test authentication via group membership. + crypted_vm_pw=`echo ${GOTSYSD_VM_PASSWORD} | encrypt | tr -d '\n'` + crypted_pw=`echo ${GOTSYSD_DEV_PASSWORD} | encrypt | tr -d '\n'` + sshkey=`cat ${GOTSYSD_SSH_PUBKEY}` + cat > ${testroot}/wt/gotsys.conf <