Release 0.9.1-3 with RetroBrowser, PPC audio, XP diagnostics and LP64 repair

This commit is contained in:
2026-11-29 13:41:59 +00:00
parent 15fde09e9e
commit 679dada6ec
117 changed files with 2473 additions and 63 deletions

View File

@@ -15,6 +15,9 @@
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
#include <spawn.h>
extern char **environ;
#include <fcntl.h>
@@ -75,6 +78,28 @@ static int gateway_api(struct mg_connection*c,int post,json_object*req,int detec
addstr(result,"status",fresh?snapshot:"Kein aktueller Gateway-Status. Dateiserver/Dispatcher starten oder Journal prüfen.");free(snapshot);
return reply(c,200,result,NULL);
}
/* Browser administration through a local, owner-only Unix socket. */
static int browser_api(struct mg_connection*c,int post,json_object*req){
if(auth_default()||no_services)return error(c,403,"Kennwort ändern oder Dienstmodus verwenden.");
if(post&&!confirm(req))return error(c,400,"Aktion bestätigen.");
if(post&&js(req,"op")&&!strcmp(js(req,"op"),"update")){
pid_t pid;char *args[]={"/usr/bin/systemctl","start","--no-block","mars-browser-update-now.service",NULL};int status;
if(posix_spawn(&pid,args[0],NULL,NULL,args,environ)||waitpid(pid,&status,0)<0||!WIFEXITED(status)||WEXITSTATUS(status))return error(c,500,"Update-Dienst konnte nicht gestartet werden.");
return ok(c,NULL);
}
int fd=socket(AF_UNIX,SOCK_STREAM|SOCK_CLOEXEC,0);if(fd<0)return error(c,500,"Browser-Socket fehlt.");
struct timeval timeout={15,0};setsockopt(fd,SOL_SOCKET,SO_RCVTIMEO,&timeout,sizeof timeout);setsockopt(fd,SOL_SOCKET,SO_SNDTIMEO,&timeout,sizeof timeout);
struct sockaddr_un a={.sun_family=AF_UNIX,.sun_path="/run/mars-browser/admin.sock"};
if(connect(fd,(struct sockaddr*)&a,sizeof a)){close(fd);return error(c,500,"Browsermodul nicht installiert, wird gestartet oder ist ausgefallen. mars_vme-Journal prüfen.");}
const char*body=post?json_object_to_json_string_ext(req,JSON_C_TO_STRING_PLAIN):"{\"op\":\"get\"}";
size_t n=strlen(body),off=0;if(n>16000){close(fd);return error(c,400,"Anfrage zu groß.");}
while(off<n){ssize_t k=send(fd,body+off,n-off,MSG_NOSIGNAL);if(k<=0)break;off+=(size_t)k;}
if(off!=n||send(fd,"\n",1,MSG_NOSIGNAL)!=1){close(fd);return error(c,500,"Browserdienst nicht erreichbar.");}
char *b=malloc(65536);if(!b){close(fd);return error(c,500,"Speicher fehlt.");}off=0;while(off<65535){ssize_t k=recv(fd,b+off,65535-off,0);if(k<=0)break;off+=(size_t)k;if(memchr(b,'\n',off))break;}close(fd);b[off]=0;
if(!memchr(b,'\n',off)){free(b);return error(c,500,"Browserdienst: unvollständige Antwort.");}
json_object *res=json_tokener_parse(b);free(b);if(!res||!json_object_is_type(res,json_type_object)){json_object_put(res);return error(c,500,"Browserdienst: ungültige Antwort.");}
return reply(c,get(res,"error")?400:200,res,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.");}
@@ -135,6 +160,23 @@ static int process(struct mg_connection*c,const struct mg_request_info*r,json_ob
}
return error(c,404,"Unbekanntes Treiberpaket.");
}
if(!post){
const char *routes[]={"/api/browser/client-windows","/api/browser/client-linux","/api/browser/client-macclassic","/api/browser/client-macclassic-source","/api/browser/mac-opentransport"};
const char *files[]={"windows-x86.zip","linux-x11.zip","macclassic-powerpc.zip","macclassic-powerpc-source.zip","Open-Transport-1-3-1.iso.zip"};
for(size_t i=0;i<sizeof(routes)/sizeof(routes[0]);i++)if(!strcmp(u,routes[i])){
if(auth_default())return error(c,403,"Kennwort ändern.");
char path[512];snprintf(path,sizeof path,"/usr/local/share/mars-vme/browser/%s",files[i]);
if(access(path,R_OK))return error(c,404,"Browser-Paket nicht installiert.");
mg_send_file(c,path);return 200;
}
}
if(!post&&!strcmp(u,"/api/browser/client-source")){
if(auth_default())return error(c,403,"Kennwort ändern.");
const char *p="/usr/local/share/mars-vme/browser-client-source.zip";
if(access(p,R_OK))return error(c,404,"Browser-Quellpaket noch nicht installiert.");
mg_send_file(c,p);return 200;
}
if(!strcmp(u,"/api/browser"))return browser_api(c,post,req);
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);