Map new SQL users to explicitly selected existing Linux accounts

This commit is contained in:
2026-12-01 12:41:25 +00:00
parent b131dcc9d6
commit 53e6c27960
12 changed files with 166 additions and 12 deletions

View File

@@ -236,7 +236,7 @@ static int process(struct mg_connection*c,const struct mg_request_info*r,json_ob
if(!post&&!strcmp(u,"/api/gateway/detect"))return gateway_api(c,0,NULL,1);
if(!post&&!strcmp(u,"/api/status"))return reply(c,200,supervisor_status(),NULL);
if(!post&&!strcmp(u,"/api/monitor")){if(auth_default())return error(c,403,"Kennwort ändern.");return reply(c,200,monitor_data(),NULL);}
if(!strcmp(u,"/api/bindery")||!strcmp(u,"/api/print")){if(auth_default()||no_services)return error(c,403,"Kennwort ändern oder Dienstmodus verwenden.");if(!post)return error(c,405,"POST erforderlich.");const char *op=js(req,"op");if(!op)return error(c,400,"Aktion fehlt.");const char *unixname=js(req,"unix");if(!strcmp(u,"/api/bindery")&&unixname&&!strncmp(unixname,"marsv",5)&&(!strcmp(op,"create-user")||!strcmp(op,"map-user")))return error(c,400,"Reservierte SQLite-Identitäten nur über die geführte Benutzeranlage verwenden.");if(!strncmp(op,"trustee-",8)&&!supervisor_config_matches())return error(c,409,"Konfiguration seit Serverstart geändert. Dateiserver neu starten.");int readonly=!strcmp(op,"sessions")||!strcmp(op,"objects")||!strcmp(op,"properties")||!strcmp(op,"list")||!strcmp(op,"script-get")||!strcmp(op,"trustee-get")||!strcmp(op,"group-members");if(!readonly&&!confirm(req))return error(c,400,"Aktion bestätigen.");json_object *res=!strcmp(u,"/api/bindery")?bindery_call(req):print_call(req);return reply(c,get(res,"error")?400:200,res,NULL);}
if(!strcmp(u,"/api/bindery")||!strcmp(u,"/api/print")){if(auth_default()||no_services)return error(c,403,"Kennwort ändern oder Dienstmodus verwenden.");if(!post)return error(c,405,"POST erforderlich.");const char *op=js(req,"op");if(!op)return error(c,400,"Aktion fehlt.");if(!strcmp(op,"map-user")&&identity_local_managed(js(req,"name")))return error(c,409,"SQL-Zuordnung geschützt: bestehende Benutzer nicht ohne geprüfte Eigentümermigration umstellen.");const char *unixname=js(req,"unix");if(!strcmp(u,"/api/bindery")&&unixname&&!strncmp(unixname,"marsv",5)&&(!strcmp(op,"create-user")||!strcmp(op,"map-user")))return error(c,400,"Reservierte SQLite-Identitäten nur über die geführte Benutzeranlage verwenden.");if(!strncmp(op,"trustee-",8)&&!supervisor_config_matches())return error(c,409,"Konfiguration seit Serverstart geändert. Dateiserver neu starten.");int readonly=!strcmp(op,"sessions")||!strcmp(op,"objects")||!strcmp(op,"properties")||!strcmp(op,"list")||!strcmp(op,"script-get")||!strcmp(op,"trustee-get")||!strcmp(op,"group-members");if(!readonly&&!confirm(req))return error(c,400,"Aktion bestätigen.");json_object *res=!strcmp(u,"/api/bindery")?bindery_call(req):print_call(req);return reply(c,get(res,"error")?400:200,res,NULL);}
char*current=read_file(config_path,MAX_CONF,0);if(!current)return error(c,500,"nwserv.conf nicht lesbar.");char rev[65];sha(current,rev);int ret=404;
if(!post&&!strcmp(u,"/api/state")){ret=reply(c,200,state(s,current),NULL);goto done;}if(!post&&!strcmp(u,"/api/download")){if(auth_default())ret=error(c,403,"Kennwort ändern.");else ret=send_data(c,200,"text/plain; charset=utf-8",current,strlen(current),NULL,NULL);goto done;}
if(!post){ret=error(c,404,"Nicht gefunden.");goto done;}const char*given=js(req,"revision");if(!given||strcmp(given,rev)){ret=error(c,409,"Konfiguration geändert. Bitte neu laden.");goto done;}