Build legacy drivers and publish per-OS packages with web activation and DEB
This commit is contained in:
@@ -44,7 +44,7 @@ static void msg(json_object*a,const char*s){json_object_array_add(a,json_object_
|
||||
static size_t count(json_object*g,const char*k){return json_object_array_length(get(g,k));}
|
||||
static const char*at(json_object*g,const char*k,size_t i){return json_object_get_string(json_object_array_get_idx(get(g,k),i));}
|
||||
static char *netprop(const char*n,const char*k){char p[PATH_MAX];snprintf(p,sizeof p,"/sys/class/net/%s/%s",n,k);/* sysfs regular attributes can report 4096 size */char*s=read_file(p,4096,0);if(s)s[strcspn(s,"\r\n")]=0;return s;}
|
||||
json_object *devices(void){json_object*a=json_object_new_array();struct if_nameindex *ifs=if_nameindex();if(!ifs)return a;for(struct if_nameindex*p=ifs;p->if_index;p++){char *t=netprop(p->if_name,"type");char w[PATH_MAX],phy[PATH_MAX];snprintf(w,sizeof w,"/sys/class/net/%s/wireless",p->if_name);snprintf(phy,sizeof phy,"/sys/class/net/%s/phy80211",p->if_name);if(t&&!strcmp(t,"1")&&access(w,F_OK)&&access(phy,F_OK)){json_object*o=json_object_new_object();char*m=netprop(p->if_name,"address"),*s=netprop(p->if_name,"operstate");addstr(o,"name",p->if_name);addstr(o,"mac",m);addstr(o,"state",s);free(m);free(s);json_object_array_add(a,o);}free(t);}if_freenameindex(ifs);return a;}
|
||||
json_object *devices(void){json_object*a=json_object_new_array();struct if_nameindex *ifs=if_nameindex();if(!ifs)return a;for(struct if_nameindex*p=ifs;p->if_index;p++){char *t=netprop(p->if_name,"type");char w[PATH_MAX],phy[PATH_MAX];snprintf(w,sizeof w,"/sys/class/net/%s/wireless",p->if_name);snprintf(phy,sizeof phy,"/sys/class/net/%s/phy80211",p->if_name);if(t&&!strcmp(t,"1")&&strcmp(p->if_name,"marsipx0")&&access(w,F_OK)&&access(phy,F_OK)){json_object*o=json_object_new_object();char*m=netprop(p->if_name,"address"),*s=netprop(p->if_name,"operstate");addstr(o,"name",p->if_name);addstr(o,"mac",m);addstr(o,"state",s);free(m);free(s);json_object_array_add(a,o);}free(t);}if_freenameindex(ifs);return a;}
|
||||
static int dev_exists(json_object*d,const char*s){for(size_t i=0;i<json_object_array_length(d);i++)if(!strcmp(s,js(json_object_array_get_idx(d,i),"name")))return 1;return 0;}
|
||||
json_object *validate(const char*s){json_object*o=json_object_new_object(),*err=json_object_new_array(),*warn=json_object_new_array(),*g=groups(s),*d=devices();json_object_object_add(o,"errors",err);json_object_object_add(o,"warnings",warn);char*copy=NULL,*a[12];int n;unsigned long long nets[33],x;size_t nn=0;char pairs[32][128];size_t np=0;
|
||||
if(count(g,"2")!=1)msg(err,"Abschnitt 2: genau ein Servername erforderlich.");else{n=tokens(at(g,"2",0),©,a,12);if(n!=1||strlen(a[0])>47||strspn(a[0],"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-")!=strlen(a[0]))msg(err,"Abschnitt 2: Servername ungültig.");free(copy);}
|
||||
|
||||
25
native/gateway_auto.c
Normal file
25
native/gateway_auto.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#define _GNU_SOURCE
|
||||
#include "gateway_auto.h"
|
||||
#include "core.h"
|
||||
#include "../src/gateway.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <net/if.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
static const char *sget(json_object *o,const char*k){const char*s=js(o,k);return s?s:"";}
|
||||
/* Fixed commands, never interpolate configuration or client input. */
|
||||
static json_object *command_json(const char *command){FILE*f=popen(command,"r");if(!f)return NULL;char *s=malloc(MAX_CONF+1);if(!s){pclose(f);return NULL;}size_t n=fread(s,1,MAX_CONF,f);int more=fgetc(f),bad=ferror(f);int rc=pclose(f);s[n]=0;json_object*o=NULL;if(!bad&&more==EOF&&rc==0)o=json_tokener_parse(s);free(s);if(!json_object_is_type(o,json_type_array)){json_object_put(o);return NULL;}return o;}
|
||||
static int prefix(const char *str,uint32_t *net,uint32_t *mask){char b[64];if(strlen(str)>=sizeof b)return -1;strcpy(b,str);char *p=strchr(b,'/');long bits=32;if(p){*p++=0;char*end;bits=strtol(p,&end,10);if(end==p||*end||bits<0||bits>32)return -1;}struct in_addr a;if(inet_pton(AF_INET,b,&a)!=1)return -1;*mask=bits?UINT32_MAX<<(32-bits):0;*net=ntohl(a.s_addr)&*mask;return 0;}
|
||||
int ga_free(json_object *routes,uint32_t ip){if(!json_object_is_type(routes,json_type_array))return 0;uint32_t subnet=ntohl(ip)&0xffffff00u;for(size_t i=0;i<json_object_array_length(routes);i++){json_object*r=json_object_array_get_idx(routes,i);const char*d=sget(r,"dst");if(!*d||!strcmp(d,"default")||!strcmp(d,"0.0.0.0/0"))continue;uint32_t net,mask;if(prefix(d,&net,&mask))return 0;/* Ignore only routes belonging to our existing TAP; restart rechecks after teardown. */if(!strcmp(sget(r,"dev"),GW_TAP)&&(net&0xffffff00u)==subnet&&mask>=0xffffff00u)continue;uint32_t common=mask&0xffffff00u;if((subnet&common)==(net&common))return 0;}return 1;}
|
||||
uint32_t ga_choose(json_object *routes){/* deterministic private /24 choices, including alternate RFC1918 ranges */for(unsigned group=0;group<3;group++){uint32_t base=group==0?0x0afa0000u:group==1?0xac1f0000u:0xc0a80000u;for(unsigned i=0;i<256;i++){uint32_t ip=htonl(base+(i<<8)+1);if(ga_free(routes,ip))return ip;}}return 0;}
|
||||
static void address(json_object*r,const char*k,uint32_t ip){char a[INET_ADDRSTRLEN];if(inet_ntop(AF_INET,&ip,a,sizeof a))addstr(r,k,a);}
|
||||
static int dns_find(const char*path,uint32_t*out){FILE*f=fopen(path,"r");if(!f)return 0;char line[512],key[32],val[128];int ok=0;while(fgets(line,sizeof line,f))if(sscanf(line,"%31s %127s",key,val)==2&&!strcmp(key,"nameserver")&&inet_pton(AF_INET,val,out)==1&&gw_public_ip(*out)){ok=1;break;}fclose(f);return ok;}
|
||||
json_object *ga_detect(const char*conf,json_object*current,char*err,size_t n){json_object *routes=command_json("PATH=/usr/sbin:/usr/bin:/sbin:/bin ip -4 -j route show table all"),*route=command_json("PATH=/usr/sbin:/usr/bin:/sbin:/bin ip -4 -j route get 1.1.1.1");json_object *out=NULL,*g=NULL;struct gw_config cfg;char why[256];if(gw_parse(current,&cfg,why,sizeof why)){snprintf(err,n,"Gespeicherte Gateway-Konfiguration ungültig: %s",why);goto done;}if(!routes||!route||!json_object_array_length(route)){snprintf(err,n,"Keine auswertbare IPv4-Route; iproute2 und Internetroute prüfen.");goto done;}json_object*r=json_object_array_get_idx(route,0);const char *dev=sget(r,"dev");if(!*dev||!strcmp(dev,GW_TAP)||!strcmp(dev,"lo")||!if_nametoindex(dev)){snprintf(err,n,"Kein geeigneter TCP/IP-Uplink gefunden.");goto done;}g=groups(conf);json_object*a=get(g,"4");unsigned long first=0,selected=0;for(size_t i=0;i<json_object_array_length(a);i++){const char*s=json_object_get_string(json_object_array_get_idx(a,i));char *end;unsigned long num=strtoul(s,&end,0);if(end==s||(*end!=' '&&*end!='\t')||!num||num>=UINT32_MAX)continue;if(!first)first=num;if(num==ntohl(cfg.net))selected=num;}if(!first){snprintf(err,n,"Zuerst ein externes IPX-Netz in nwserv.conf speichern.");goto done;}if(cfg.count&&!selected){snprintf(err,n,"Reservierungen vorhanden, aber ihr IPX-Netz fehlt. Manuell prüfen.");goto done;}uint32_t ip=cfg.ip;if(!ga_free(routes,ip)){if(cfg.count){snprintf(err,n,"Reserviertes TAP-Netz überschneidet sich mit einer Route. Clients nicht automatisch umadressieren.");goto done;}ip=ga_choose(routes);}if(!ip){snprintf(err,n,"Kein konfliktfreies /24 aus den Vorschlagsbereichen gefunden.");goto done;}uint32_t dns=0;int local=dns_find("/run/systemd/resolve/resolv.conf",&dns)||dns_find("/etc/resolv.conf",&dns);if(!local)dns=cfg.dns;out=json_object_new_object();char net[16];snprintf(net,sizeof net,"0x%X",(unsigned)(selected?selected:first));addstr(out,"network",net);addstr(out,"uplink",dev);addstr(out,"localIP",sget(r,"prefsrc"));addstr(out,"localGateway",sget(r,"gateway"));address(out,"gateway",ip);address(out,"dns",dns);addstr(out,"dnsSource",local?"Öffentlicher IPv4-Resolver des Hosts":"Vorhandener öffentlicher DNS (lokale/private Resolver sind gesperrt)");
|
||||
struct ifaddrs*ifs;if(!getifaddrs(&ifs)){for(struct ifaddrs*p=ifs;p;p=p->ifa_next)if(p->ifa_addr&&p->ifa_netmask&&p->ifa_addr->sa_family==AF_INET&&!strcmp(p->ifa_name,dev)){struct sockaddr_in *sa=(void*)p->ifa_addr,*m=(void*)p->ifa_netmask;struct in_addr wanted;if(inet_pton(AF_INET,sget(r,"prefsrc"),&wanted)==1&&sa->sin_addr.s_addr!=wanted.s_addr)continue;address(out,"localIP",sa->sin_addr.s_addr);address(out,"localMask",m->sin_addr.s_addr);break;}freeifaddrs(ifs);}
|
||||
FILE*f=fopen("/proc/sys/net/ipv4/ip_forward","r");int v=0;if(f){if(fscanf(f,"%d",&v)!=1)v=0;fclose(f);}json_object_object_add(out,"forwarding",json_object_new_boolean(v==1));
|
||||
done:json_object_put(g);json_object_put(routes);json_object_put(route);return out;}
|
||||
10
native/gateway_auto.h
Normal file
10
native/gateway_auto.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#ifndef MARS_GATEWAY_AUTO_H
|
||||
#define MARS_GATEWAY_AUTO_H
|
||||
#include <json-c/json.h>
|
||||
#include <stdint.h>
|
||||
/* Routes are ip -4 -j route show table all objects. Network byte order. */
|
||||
int ga_free(json_object *routes,uint32_t ip);
|
||||
uint32_t ga_choose(json_object *routes);
|
||||
json_object *ga_detect(const char *conf,json_object *current,char *err,size_t n);
|
||||
#endif
|
||||
@@ -3,14 +3,20 @@
|
||||
#include "core.h"
|
||||
#include "supervisor.h"
|
||||
#include "admin.h"
|
||||
#include "../src/gateway.h"
|
||||
#include "gateway_auto.h"
|
||||
#include <civetweb.h>
|
||||
#include <pthread.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/wait.h>
|
||||
#include <spawn.h>
|
||||
extern char **environ;
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -46,12 +52,77 @@ static json_object *state(struct session*s,const char*current){json_object*o=jso
|
||||
static char *comparison(const char*a,const char*b){if(!strcmp(a,b))return strdup("");char*s=NULL;if(asprintf(&s,"--- Aktuell (vollständig) ---\n%s\n+++ Entwurf (vollständig) +++\n%s",a,b)<0)return NULL;return s;}
|
||||
static int confirm(json_object*r){json_object*v=get(r,"confirm");return json_object_is_type(v,json_type_boolean)&&json_object_get_boolean(v);}
|
||||
static int config_valid(const char*s){json_object*v=validate(s);int ok=json_object_array_length(get(v,"errors"))==0;json_object_put(v);return ok;}
|
||||
/* Gateway configuration is independent of nwserv.conf, but references its saved IPX network. */
|
||||
static int gateway_network_exists(uint32_t net){char*conf=read_file(config_path,MAX_CONF,0);if(!conf)return 0;json_object*g=groups(conf);free(conf);json_object*a=get(g,"4");int found=0;for(size_t i=0;i<json_object_array_length(a);i++){const char*s=json_object_get_string(json_object_array_get_idx(a,i));char *end;unsigned long n=strtoul(s,&end,0);if(end!=s&&(*end==' '||*end=='\t')&&n==ntohl(net)){found=1;break;}}json_object_put(g);return found;}
|
||||
static int gateway_api(struct mg_connection*c,int post,json_object*req,int detect){
|
||||
if(auth_default()||no_services)return error(c,403,"Gateway nur im eingerichteten Dienstmodus verfügbar.");
|
||||
char *old=read_file(GW_CONFIG,16384,1);int configured=old!=NULL;json_object*current=NULL;
|
||||
if(!old){if(errno!=ENOENT)return error(c,500,"Gateway-Konfiguration nicht lesbar; Linux-Konsole prüfen.");current=gw_default();old=strdup(json_object_to_json_string_ext(current,JSON_C_TO_STRING_PLAIN));}else current=json_tokener_parse(old);
|
||||
if(!old||!current){free(old);json_object_put(current);return error(c,500,"Gateway-Konfiguration ungültig.");}
|
||||
char rev[65];sha(old,rev);
|
||||
if(detect){char err[512];char*conf=read_file(config_path,MAX_CONF,0);if(!conf)snprintf(err,sizeof err,"NetWare-Konfiguration nicht lesbar.");json_object*out=conf?ga_detect(conf,current,err,sizeof err):NULL;free(conf);free(old);json_object_put(current);if(!out)return error(c,400,err);return reply(c,200,out,NULL);}
|
||||
if(post){const char*given=js(req,"revision");json_object*next=get(req,"config");struct gw_config cfg;char msg[256];int code=0;
|
||||
if(!given||strcmp(given,rev)){snprintf(msg,sizeof msg,"Gateway-Konfiguration inzwischen geändert.");code=409;}
|
||||
else if(!confirm(req)){snprintf(msg,sizeof msg,"Änderung bestätigen.");code=400;}
|
||||
else if(gw_parse(next,&cfg,msg,sizeof msg))code=400;
|
||||
else if(cfg.enabled&&(!gateway_network_exists(cfg.net)||!if_nametoindex(cfg.uplink))){snprintf(msg,sizeof msg,"Gespeichertes externes IPX-Netz und vorhandenen Uplink wählen.");code=400;}
|
||||
else{const char*text=json_object_to_json_string_ext(next,JSON_C_TO_STRING_PLAIN);if(strlen(text)>16384){snprintf(msg,sizeof msg,"Konfiguration zu groß.");code=400;}else if(atomic_write(GW_CONFIG ".previous",old,strlen(old),0600)||atomic_write(GW_CONFIG,text,strlen(text),0600)){snprintf(msg,sizeof msg,"Gateway-Konfiguration konnte nicht gesichert/geschrieben werden.");code=500;}}
|
||||
free(old);json_object_put(current);if(code)return error(c,code,msg);return ok(c,NULL);
|
||||
}
|
||||
json_object*result=json_object_new_object();json_object_object_add(result,"config",current);json_object_object_add(result,"configured",json_object_new_boolean(configured));addstr(result,"revision",rev);free(old);
|
||||
char *snapshot=read_file(GW_STATUS,16384,1);struct stat st;int fresh=snapshot&&!stat(GW_STATUS,&st)&&time(NULL)-st.st_mtime>=0&&time(NULL)-st.st_mtime<4;
|
||||
char *seen=read_file(GW_DISCOVERY,16384,1);struct stat ds;json_object*peers=seen&&!stat(GW_DISCOVERY,&ds)&&time(NULL)-ds.st_mtime>=0&&time(NULL)-ds.st_mtime<4?json_tokener_parse(seen):NULL;free(seen);if(!json_object_is_type(peers,json_type_array)){json_object_put(peers);peers=json_object_new_array();}json_object_object_add(result,"observed",peers);
|
||||
addstr(result,"status",fresh?snapshot:"Kein aktueller Gateway-Status. Dateiserver/Dispatcher starten oder Journal prüfen.");free(snapshot);
|
||||
return reply(c,200,result,NULL);
|
||||
}
|
||||
static int process(struct mg_connection*c,const struct mg_request_info*r,json_object*req){const char*u=r->local_uri;int post=!strcmp(r->request_method,"POST");struct session*s=session_get(c);char cookie[256];if(post&&!strcmp(u,"/api/login")){struct attempt*a=rate(r->remote_addr);if(!a||a->count>=5)return error(c,429,"Zu viele Versuche. Eine Minute warten.");const char*user=js(req,"user");if(!user||strcmp(user,"admin")||!auth_verify(js(req,"password"))){a->count++;return error(c,401,"Anmeldung fehlgeschlagen.");}a->count=0;if(!(s=new_session()))return error(c,429,"Zu viele aktive Sitzungen.");cookie_str(cookie,s->token);return ok(c,cookie);}
|
||||
const char*file=NULL,*type=NULL;if(!post){if(!strcmp(u,"/login")){file="login.html";type="text/html";}else if(!strcmp(u,"/login.js")){file="login.js";type="text/javascript";}else if(!strcmp(u,"/style.css")){file="style.css";type="text/css";}}
|
||||
if(!file&&!s){if(!strcmp(u,"/"))return send_data(c,303,"text/plain","",0,NULL,"/login");return error(c,401,"Anmeldung erforderlich.");}
|
||||
if(post){const char*csrf=mg_get_header(c,"X-Mars-CSRF");if(!csrf||strlen(csrf)!=64||CRYPTO_memcmp(csrf,s->csrf,64))return error(c,403,"CSRF-Prüfung fehlgeschlagen.");if(!strcmp(u,"/api/logout")){memset(s,0,sizeof *s);cookie_str(cookie,"");return ok(c,cookie);}if(!strcmp(u,"/api/password")){const char*next=js(req,"new"),*rep=js(req,"repeat");if(!auth_verify(js(req,"current"))||!next||!rep||strcmp(next,rep)||auth_set(next,0))return error(c,400,"Aktuelles Kennwort prüfen; neues Kennwort 10–256 Zeichen, zweimal identisch.");memset(sessions,0,sizeof sessions);cookie_str(cookie,"");return ok(c,cookie);}if(auth_default())return error(c,403,"Zuerst das Web-Standardkennwort ändern.");}
|
||||
if(!post&&!file){if(!strcmp(u,"/")){file="index.html";type="text/html";}else if(!strcmp(u,"/app.js")){file="app.js";type="text/javascript";}}
|
||||
if(file){char*p=NULL;asprintf(&p,"%s/%s",assets,file);char*d=p?read_file(p,MAX_CONF,0):NULL;free(p);if(!d)return error(c,404,"Datei fehlt.");char mime[64];snprintf(mime,sizeof mime,"%s; charset=utf-8",type);int code=send_data(c,200,mime,d,strlen(d),NULL,NULL);free(d);return code;}
|
||||
if(post&&!strcmp(u,"/api/drivers/activate")){
|
||||
if(no_services||!confirm(req))return error(c,400,"Dienstmodus und Bestätigung erforderlich.");
|
||||
json_object *platforms=get(req,"platforms");
|
||||
if(!json_object_is_type(platforms,json_type_array)||json_object_array_length(platforms)<1||json_object_array_length(platforms)>6)return error(c,400,"Mindestens ein Betriebssystem wählen.");
|
||||
pid_t pid;int status;char *args[18]={"/usr/local/libexec/mars-install-drivers","--packages","/usr/local/share/mars-vme/driver-packages"};int ac=3;
|
||||
for(size_t i=0;i<json_object_array_length(platforms);i++){
|
||||
const char *os=json_object_get_string(json_object_array_get_idx(platforms,i));
|
||||
if(!os||(strcmp(os,"WIN95")&&strcmp(os,"WIN98")&&strcmp(os,"WINME")&&strcmp(os,"WINNT40")&&strcmp(os,"WIN2000")&&strcmp(os,"WINXP")))return error(c,400,"Unbekanntes Betriebssystem.");
|
||||
args[ac++]="--os";args[ac++]=(char*)os;
|
||||
}
|
||||
args[ac]=NULL;
|
||||
if(posix_spawn(&pid,args[0],NULL,NULL,args,environ))return error(c,500,"Treiber-Installer fehlt. DEB oder install.sh aktualisieren.");
|
||||
pid_t done;do{done=waitpid(pid,&status,0);}while(done<0&&errno==EINTR);
|
||||
if(done!=pid||!WIFEXITED(status)||WEXITSTATUS(status))return error(c,500,"Bereitstellung fehlgeschlagen: SYS/PUBLIC einrichten; Details im Dienstjournal.");
|
||||
return ok(c,NULL);
|
||||
}
|
||||
if(!post&&!strcmp(u,"/api/drivers")){
|
||||
char path[PATH_MAX];snprintf(path,sizeof path,"%s/drivers/enabled.json",assets);char *data=read_file(path,4096,0);
|
||||
json_object *result=data?json_tokener_parse(data):NULL;free(data);
|
||||
if(!result)result=json_tokener_parse("{\"platforms\":[],\"map\":\"\"}");
|
||||
return reply(c,200,result,NULL);
|
||||
}
|
||||
/* Fixed allowlist only; never interpolate a request path into the filesystem. */
|
||||
if(!post&&!strncmp(u,"/drivers/",9)){
|
||||
if(auth_default())return error(c,403,"Kennwort ändern.");
|
||||
static const char *names[]={"WIN95.zip","WIN98.zip","WINME.zip","WINNT40.zip","WIN2000.zip","WINXP.zip",NULL};
|
||||
for(int i=0;names[i];i++)if(!strcmp(u+9,names[i])){
|
||||
char settings[PATH_MAX];snprintf(settings,sizeof settings,"%s/drivers/enabled.json",assets);
|
||||
char *data=read_file(settings,4096,0);json_object *enabled=data?json_tokener_parse(data):NULL;free(data);int allowed=0;
|
||||
json_object *list=get(enabled,"platforms");
|
||||
if(json_object_is_type(list,json_type_array))for(size_t j=0;j<json_object_array_length(list);j++){
|
||||
const char *os=json_object_get_string(json_object_array_get_idx(list,j));char name[32];snprintf(name,sizeof name,"%s.zip",os?os:"");if(!strcmp(name,names[i]))allowed=1;
|
||||
}
|
||||
json_object_put(enabled);if(!allowed)return error(c,404,"Treiberpaket nicht freigegeben.");
|
||||
char path[PATH_MAX];struct stat st;
|
||||
if(snprintf(path,sizeof path,"%s/drivers/%s",assets,names[i])>=(int)sizeof path||lstat(path,&st)||!S_ISREG(st.st_mode))return error(c,404,"Treiberpaket nicht installiert.");
|
||||
mg_send_file(c,path);return 200;
|
||||
}
|
||||
return error(c,404,"Unbekanntes Treiberpaket.");
|
||||
}
|
||||
if(!strcmp(u,"/api/gateway"))return gateway_api(c,post,req,0);
|
||||
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.");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);}
|
||||
|
||||
Reference in New Issue
Block a user