From 53e6c279604fc3eed9231f0435f4e1e86ec4ab87 Mon Sep 17 00:00:00 2001 From: deviloper Date: Tue, 1 Dec 2026 12:41:25 +0000 Subject: [PATCH] Map new SQL users to explicitly selected existing Linux accounts --- Makefile | 8 +++++ SQLITE-IDENTITIES.md | 35 +++++++++++++++++++ native/identity.c | 2 +- native/identity_api.c | 48 ++++++++++++++++++++++++++- native/identity_api.h | 1 + native/main.c | 2 +- packaging/build-deb.py | 4 +-- tests/test_bindery_isolated.sh | 24 +++++++++++++- tests/test_identity_wizard_browser.py | 7 ++-- tests/test_local_mapping.c | 31 +++++++++++++++++ websetup/app.js | 14 ++++++-- websetup/index.html | 2 +- 12 files changed, 166 insertions(+), 12 deletions(-) create mode 100644 tests/test_local_mapping.c diff --git a/Makefile b/Makefile index 9a5a30b..0376ab3 100644 --- a/Makefile +++ b/Makefile @@ -240,3 +240,11 @@ check-nds-ncpfs: | build check-default-identity: python3 tests/test_default_identity.py check-release: check-default-identity + +build/test-local-mapping: tests/test_local_mapping.c native/identity.c native/identity_api.c native/core.c | build + $(CC) $(CFLAGS) -Werror -std=c11 -Inative $(NATIVE_FLAGS) -DMARS_ID_TESTING '-DMARS_ID_DB="$(abspath build/identity-test/local.sqlite3)"' tests/test_local_mapping.c native/identity.c native/identity_api.c native/core.c $(NATIVE_LIBS) -lsqlite3 -o $@ +.PHONY: check-local-mapping +check-local-mapping: build/test-local-mapping + mkdir -p build/identity-test + ./build/test-local-mapping +check-release: check-local-mapping diff --git a/SQLITE-IDENTITIES.md b/SQLITE-IDENTITIES.md index f2d07e0..e14ffdd 100644 --- a/SQLITE-IDENTITIES.md +++ b/SQLITE-IDENTITIES.md @@ -40,3 +40,38 @@ Use an isolated retro LAN, preferably HTTPS for web administration. Classic NetW ## Testing / release gate `make check-identity` tests local SQLite allocation and C linker wrappers, including real Linux DAC separation when run as root, and mocked Bindery API interactions. `make check-directory` and `node tests/test_directory_ui.cjs` verify the existing wizard. These do not prove NetWare login or trustee behavior. Required end-to-end acceptance on a test installation: create two users, verify no entries in `/etc/passwd`, log in from XP and DOS, test separate private files, EVERYONE membership, trustees, password change, disable/enable, reconnect after restart, deletion and no UID reuse. Test existing real Linux account login and permissions too. Audit numeric UID/GID use in upstream `nwconn`, `nwbind`, quota, print and trustee paths. Full source tree and CivetWeb dev headers were not available for this build in the development environment. No NDS login can be tested until a real NDAP implementation is available. + +## 0.9.8-4: SQL users mapped to an existing Linux account + +The default frontend action is now **SQL-Benutzer mit Linux-Konto**. Select an +existing local account explicitly; its name, UID and primary GID are shown. +Eligible accounts have UID 1000–59999, nonzero GID and names up to 19 characters +(the Bindery UNIX_USER field limit). Root, nobody and reserved virtual aliases +are excluded. No account is automatically selected or created. + +SQLite adds `local_mappings(name, unix_name, uid, gid, created_at)` alongside the +unchanged virtual identities table. Linux passwords and NetWare passwords are +not stored in this mapping table. NetWare passwords remain in Bindery. +The Bindery maps directly to the selected real Unix name; native Unix account +lookup and supplementary groups are used at runtime. Stored UID/GID are audit +snapshots, not an alternative NSS database or an automatic account migration. +Account changes are reported by identity inspection; administrators must not +recycle accounts or UIDs behind active mappings. + +Several NetWare users can intentionally share one Linux account. They then +share Unix file ownership and filesystem permissions. NetWare trustees can +restrict NetWare access additionally but do not grant rights to Samba. +No directories, ownership, ACLs, Linux groups, Samba configuration or passwords +are changed by user creation. Old virtual identities continue working unchanged. + +The API requires the selected UID/GID and an explicit shared-rights confirmation. +SQL reservation precedes Bindery creation; failures retain the reservation and +must be investigated, not retried blindly. Live Bindery readback verifies the +new mapping. Legacy direct remapping is blocked for SQL-managed local mappings; +no automatic migration of existing accounts or owned files is provided. + +Tests cover mocked API errors and shared mappings, real isolated HTTP/SQLite/ +Bindery creation of two users mapped to one local account, and the actual mobile +Chromium selection dialog with mocked API. Simultaneous Samba/NetWare writes and +file locking are not validated; a real XP login with newly mapped users remains +a client acceptance test. diff --git a/native/identity.c b/native/identity.c index 607d89c..4f2f69c 100644 --- a/native/identity.c +++ b/native/identity.c @@ -39,7 +39,7 @@ static uid_t owner(void){ static int safe_path(int write){char dir[sizeof(MARS_ID_DB)];strcpy(dir,MARS_ID_DB);char *s=strrchr(dir,'/');if(!s)return -1;*s=0;struct stat st;if(lstat(dir,&st)||!S_ISDIR(st.st_mode)||st.st_uid!=owner()||(st.st_mode&022))return -1; if(lstat(MARS_ID_DB,&st)){if(errno!=ENOENT)return -1;if(!write)return 1;int fd=open(MARS_ID_DB,O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW|O_CLOEXEC,0644);if(fd<0)return -1;int r=fchmod(fd,0644);if(close(fd))r=-1;return r;} return S_ISREG(st.st_mode)&&st.st_uid==owner()&&!(st.st_mode&022)&&st.st_nlink==1?0:-1;} -int mars_id_open(sqlite3 **db,int write){*db=NULL;int p=safe_path(write);if(p)return p;int flags=(write?SQLITE_OPEN_READWRITE:SQLITE_OPEN_READONLY)|SQLITE_OPEN_NOFOLLOW; if(sqlite3_open_v2(MARS_ID_DB,db,flags,NULL)!=SQLITE_OK)goto fail;sqlite3_busy_timeout(*db,2000);if(write&&sqlite3_exec(*db,"CREATE TABLE IF NOT EXISTS identities(uid INTEGER PRIMARY KEY CHECK(uid BETWEEN 200000000 AND 200099999),alias TEXT NOT NULL UNIQUE,name TEXT NOT NULL,created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP);",NULL,NULL,NULL)!=SQLITE_OK)goto fail;return 0; +int mars_id_open(sqlite3 **db,int write){*db=NULL;int p=safe_path(write);if(p)return p;int flags=(write?SQLITE_OPEN_READWRITE:SQLITE_OPEN_READONLY)|SQLITE_OPEN_NOFOLLOW; if(sqlite3_open_v2(MARS_ID_DB,db,flags,NULL)!=SQLITE_OK)goto fail;sqlite3_busy_timeout(*db,2000);if(write&&sqlite3_exec(*db,"CREATE TABLE IF NOT EXISTS identities(uid INTEGER PRIMARY KEY CHECK(uid BETWEEN 200000000 AND 200099999),alias TEXT NOT NULL UNIQUE,name TEXT NOT NULL,created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP);CREATE TABLE IF NOT EXISTS local_mappings(name TEXT PRIMARY KEY,unix_name TEXT NOT NULL,uid INTEGER NOT NULL CHECK(uid>0),gid INTEGER NOT NULL CHECK(gid>0),created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP);",NULL,NULL,NULL)!=SQLITE_OK)goto fail;return 0; fail:sqlite3_close(*db);*db=NULL;return -1;} int mars_id_name_valid(const char *s){return s&&*s&&strlen(s)<48&&strspn(s,"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-")==strlen(s)&&strcmp(s,"SUPERVISOR")&&strcmp(s,"EVERYONE");} static int row(sqlite3_stmt *q,struct mars_identity *out){int rc=sqlite3_step(q);if(rc==SQLITE_DONE)return 1;if(rc!=SQLITE_ROW)return -1;int uid=sqlite3_column_int(q,0);const char *a=(const char*)sqlite3_column_text(q,1),*n=(const char*)sqlite3_column_text(q,2);char expected[20];snprintf(expected,sizeof expected,"marsv%09d",uid);if(uidMARS_UID_LAST||!a||strcmp(a,expected)||!mars_id_name_valid(n))return -1;out->uid=uid;strcpy(out->alias,a);strcpy(out->name,n);return 0;} diff --git a/native/identity_api.c b/native/identity_api.c index 45a1292..c494576 100644 --- a/native/identity_api.c +++ b/native/identity_api.c @@ -1,5 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#define _GNU_SOURCE #include "identity_api.h" +#include +#include +#include #include "identity.h" #include "admin.h" #include @@ -11,6 +15,47 @@ static int supported(void){json_object *p=call("identity-capabilities",NULL);int static int complete(json_object *live){return live&&!get(live,"error")&&json_object_is_type(get(live,"objects"),json_type_array)&&!json_object_get_boolean(get(live,"truncated"));} static int user(json_object *x){return json_object_get_int(get(x,"type"))==1&&js(x,"name");} static void issue(json_object *a,const char *name,const char *code,const char *detail){json_object *o=json_object_new_object();addstr(o,"name",name);addstr(o,"code",code);addstr(o,"detail",detail);json_object_array_add(a,o);} + +static int local_account(const char *name,int *uid,int *gid){ + struct passwd p,*found=NULL;char buf[16384]; + if(!name||!*name||strlen(name)>19||!strncmp(name,"marsv",5)||getpwnam_r(name,&p,buf,sizeof buf,&found)||!found||p.pw_uid<1000||p.pw_uid>=60000||!p.pw_gid||p.pw_gid>INT_MAX)return -1; + *uid=(int)p.pw_uid;*gid=(int)p.pw_gid;return 0; +} +static json_object *local_users(void){ + json_object *a=json_object_new_array();FILE *f=fopen("/etc/passwd","r");if(!f)return a;struct passwd *p; + while((p=fgetpwent(f))&&json_object_array_length(a)<1000){char name[256];snprintf(name,sizeof name,"%s",p->pw_name);int uid,gid;if(local_account(name,&uid,&gid))continue; + json_object *x=json_object_new_object();addstr(x,"name",name);json_object_object_add(x,"uid",json_object_new_int(uid));json_object_object_add(x,"gid",json_object_new_int(gid));json_object_array_add(a,x);} + fclose(f);return a; +} +static int local_table(sqlite3 *db){sqlite3_stmt *q=NULL;int yes=0;if(sqlite3_prepare_v2(db,"SELECT 1 FROM sqlite_master WHERE type='table' AND name='local_mappings'",-1,&q,NULL)==SQLITE_OK)yes=sqlite3_step(q)==SQLITE_ROW;sqlite3_finalize(q);return yes;} +int identity_local_managed(const char *name){ + sqlite3 *db;int rc=mars_id_open(&db,0);if(rc)return rc<0?1:0;int found=0;sqlite3_stmt *q=NULL; + if(local_table(db)){if(sqlite3_prepare_v2(db,"SELECT 1 FROM local_mappings WHERE name=?",-1,&q,NULL)!=SQLITE_OK)found=1;else{sqlite3_bind_text(q,1,name?name:"",-1,SQLITE_TRANSIENT);int step=sqlite3_step(q);found=step!=SQLITE_DONE;}} + sqlite3_finalize(q);sqlite3_close(db);return found; +} +static json_object *local_report(json_object *objects,int full){ + json_object *a=json_object_new_array();sqlite3 *db;if(mars_id_open(&db,0))return a;sqlite3_stmt *q=NULL; + if(local_table(db)&&sqlite3_prepare_v2(db,"SELECT name,unix_name,uid,gid FROM local_mappings ORDER BY name LIMIT 1000",-1,&q,NULL)==SQLITE_OK){while(sqlite3_step(q)==SQLITE_ROW){ + const char *name=(const char*)sqlite3_column_text(q,0),*unixname=(const char*)sqlite3_column_text(q,1);int uid=sqlite3_column_int(q,2),gid=sqlite3_column_int(q,3),current_uid,current_gid; + const char *status="unknown";int valid=!local_account(unixname,¤t_uid,¤t_gid)&&uid==current_uid&&gid==current_gid; + if(!valid)status="account-changed";else if(full){status="reserved";for(size_t i=0;i1?"conflict":exact==1?"linked":"reserved";if(other||exact>1)issue(issues,name,"alias-conflict","Virtuelle UID ist mehreren oder falschen Konten zugeordnet.");}addstr(x,"status",status); }if(rc!=SQLITE_ROW&&rc!=SQLITE_DONE)addstr(o,"databaseError","SQLite-Lesefehler.");}sqlite3_finalize(q);sqlite3_close(db);} if(full)for(size_t i=0;i63||strspn(p,"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+-=.,:;")!=strlen(p))return err("Name oder NetWare-Kennwort ungültig (8–63 Großbuchstaben/ASCII).");if(!supported())return err("nwbind unterstützt SQLite-Identitäten noch nicht. Upstream neu bauen und Dienst neu starten.");json_object *audit=identity_status();int unsafe=get(audit,"databaseError")!=NULL||!json_object_get_boolean(get(audit,"liveComplete"));json_object *issues=get(audit,"issues");for(size_t i=0;i\n\nPackage: mars-vme\nArchitecture: any\nDescription: MARS VME\n') elfs=[p for p in stage.rglob('*') if p.is_file() and p.read_bytes()[:4]==b'\x7fELF'] deps=run('dpkg-shlibdeps','-O',*[str(p) for p in elfs],cwd=tmp).strip().split('shlibs:Depends=',1)[1] - (deb/'control').write_text(f'Package: mars-vme\nVersion: 0.9.8-3\nArchitecture: {arch}\nMaintainer: MARS VME \nDepends: {deps}, python3, jq, iproute2, nftables, libpcap0.8t64, nodejs (>= 20), ffmpeg, pulseaudio, pulseaudio-utils, util-linux, zip, passwd\nRecommends: chromium | google-chrome-stable\nSection: net\nPriority: optional\nDescription: MARS VME server with web administration and Windows driver packages\n Host-native Ubuntu 26.04 build. Windows drivers are experimental.\n') + (deb/'control').write_text(f'Package: mars-vme\nVersion: 0.9.8-4\nArchitecture: {arch}\nMaintainer: MARS VME \nDepends: {deps}, python3, jq, iproute2, nftables, libpcap0.8t64, nodejs (>= 20), ffmpeg, pulseaudio, pulseaudio-utils, util-linux, zip, passwd\nRecommends: chromium | google-chrome-stable\nSection: net\nPriority: optional\nDescription: MARS VME server with web administration and Windows driver packages\n Host-native Ubuntu 26.04 build. Windows drivers are experimental.\n') (deb/'preinst').write_text('#!/bin/sh\nset -e\nbase=/var/lib/mars_nwe/bindery\nif [ -s "$base/nwobj.pag" ] && [ ! -f "$base/.mars-fixed-width-v1" ]; then\n echo \'Upgrade blocked: existing Bindery may use the incompatible old LP64 layout.\' >&2\n echo \'Back up configuration, Bindery and trustees; migrate/recreate and verify it before this upgrade.\' >&2\n echo \'Do not simply create the marker on an old database. See SERVER-64BIT-REPAIR.md.\' >&2\n exit 1\nfi\n') (deb/'postinst').write_text('''#!/bin/sh set -e @@ -74,6 +74,6 @@ fi (deb/'conffiles').write_text(''.join('/'+str(f.relative_to(stage))+'\n' for f in (stage/'usr/local/etc').rglob('*') if f.is_file())) for name in ('preinst','postinst','prerm'):(deb/name).chmod(0o755) for name in ('COPYING','LEGACY-BUILD.md','WINDOWS.md','DRIVER-RELEASE.md','LONG-NAMES.md','BROWSER.md','BUILD-RETROBROWSER.md','MARS-BROWSER-LIFECYCLE.md','SERVER-64BIT-REPAIR.md','RELEASE-0.9.3-SLP-DE.md','SQLITE-IDENTITIES.md','DIRECTORY-WIZARD.md','TOKENFIX.md','RELEASE-0.9.8-NDS-WIRE-DE.md','SERVICES.md'):copy(name,'usr/share/doc/mars-vme/'+name) - package=out/f'mars-vme_0.9.8-3_{arch}.deb';run('dpkg-deb','--root-owner-group','--build',str(stage),str(package)) + package=out/f'mars-vme_0.9.8-4_{arch}.deb';run('dpkg-deb','--root-owner-group','--build',str(stage),str(package)) (out/'SHA256SUMS').write_text(''.join(hashlib.sha256(f.read_bytes()).hexdigest()+' '+f.name+'\n' for f in sorted(out.glob('*.deb')))) print(package) diff --git a/tests/test_bindery_isolated.sh b/tests/test_bindery_isolated.sh index f87bbb5..c1f6b58 100755 --- a/tests/test_bindery_isolated.sh +++ b/tests/test_bindery_isolated.sh @@ -4,8 +4,9 @@ set -euo pipefail cd "$(dirname "$0")/.." root=$PWD scratch=$(mktemp -d "$root/build/bindery-test.XXXXXX") -mkdir -p "$scratch"/{config,state/bindery,vol/SYS/public,sbin} +mkdir -p "$scratch"/{config,state/bindery,identities,vmestate,vol/SYS/public,sbin} cp upstream/build/src/{nwserv,nwbind,nwconn,ncpserv,dbmtool} "$scratch/sbin/" +cp build/mars_vme "$scratch/sbin/" cp build/mars-pcapd "$scratch/sbin/" cat > "$scratch/config/nwserv.conf" <<'CONF' 2 MARSTEST @@ -23,14 +24,19 @@ s=$1 mount --make-rprivate / mount --bind "$s/config" /usr/local/etc/mars_nwe mount --bind "$s/state" /var/lib/mars_nwe +mount --bind "$s/identities" /var/lib/mars-identities +mount --bind "$s/vmestate" /var/lib/mars-vme mount --bind "$s/vol" /var/mars_nwe mount --bind "$s/sbin" /usr/local/sbin mount -t tmpfs tmpfs /run mkdir -m700 /run/mars-pcap +ip link set lo up /usr/local/sbin/mars-pcapd --offline-test >"$s/broker.log" 2>&1 & for i in {1..50}; do [[ ! -S /run/mars-pcap/transport.sock ]] || break; sleep .1; done /usr/local/sbin/nwserv >"$s/server.log" 2>&1 & for i in {1..100}; do [[ ! -S /run/mars-pcap/admin.sock ]] || break; sleep .1; done +/usr/local/sbin/mars_vme --bind 127.0.0.1 --port 18789 --no-autostart >"$s/web.log" 2>&1 & +for i in {1..100}; do if curl -fsS http://127.0.0.1:18789/login >/dev/null 2>&1; then break; fi; sleep .1; done python3 - <<'PY' import socket,json @@ -42,6 +48,22 @@ assert u.get('unix')=='nobody',u props=query({'op':'properties','name':'SUPERVISOR','type':1})['properties'] names={p['name'] for p in props} assert {'UNIX_USER','PASSWORD','SECURITY_EQUALS',"GROUPS_I'M_IN"}.issubset(names), names +import urllib.request,http.cookiejar +base='http://127.0.0.1:18789';csrf='' +opener=urllib.request.build_opener(urllib.request.HTTPCookieProcessor(http.cookiejar.CookieJar())) +def api(path,data=None): + req=urllib.request.Request(base+path,data=json.dumps(data).encode() if data is not None else None,headers={'Origin':base,'Content-Type':'application/json','X-Mars-CSRF':csrf}) + with opener.open(req,timeout=10) as response:return json.load(response) +api('/api/login',{'user':'admin','password':'admin'});csrf=api('/api/state')['csrf'] +api('/api/password',{'current':'admin','new':'LOCALTESTPASS123','repeat':'LOCALTESTPASS123'}) +api('/api/login',{'user':'admin','password':'LOCALTESTPASS123'});csrf=api('/api/state')['csrf'] +users=api('/api/identities')['localUsers'];assert users +chosen=users[0] +for name in ['MAPALICE','MAPBOB']: + result=api('/api/identities',dict(op='create',name=name,password='TESTPASS123',unix=chosen['name'],uid=chosen['uid'],gid=chosen['gid'],sharedConfirmed=True,confirm=True)) + assert result['unix']==chosen['name'] +mappings=api('/api/identities')['localMappings'];assert len(mappings)==2 and all(x['status']=='linked' for x in mappings),mappings +print('PASS isolated real HTTP + nwbind + SQLite: two independent NetWare users share the chosen Linux account') print('PASS isolated real nwbind: SUPERVISOR mapping and independent properties', sorted(names)) PY NS diff --git a/tests/test_identity_wizard_browser.py b/tests/test_identity_wizard_browser.py index 95e5baa..8bb5c91 100644 --- a/tests/test_identity_wizard_browser.py +++ b/tests/test_identity_wizard_browser.py @@ -24,8 +24,9 @@ def fixture(source,path,body): if path=='/api/identities': if body: assert body['confirm'] and body['name']=='ALICE' and len(body['password'])==20 - created+=1;objects.append({'name':'ALICE','type':1,'unix':'marsv200000000','id':3,'disabled':False});return {'alias':'marsv200000000','uid':200000000} - return dict(wrappedBindery=True,liveComplete=True,databaseAvailable=True,identities=[{'name':'ALICE','alias':'marsv200000000','uid':200000000,'status':'linked'}] if created else [],issues=[]) + assert body['unix']=='chris' and body['uid']==1000 and body['gid']==1000 and body['sharedConfirmed'] + created+=1;objects.append({'name':'ALICE','type':1,'unix':'chris','id':3,'disabled':False});return {'alias':'chris','unix':'chris','uid':1000} + return dict(localUsers=[{'name':'chris','uid':1000,'gid':1000}],localMappings=[],wrappedBindery=True,liveComplete=True,databaseAvailable=True,identities=[{'name':'ALICE','alias':'marsv200000000','uid':200000000,'status':'linked'}] if created else [],issues=[]) if path=='/api/bindery' and body['op']=='objects':return {'objects':objects} raise AssertionError((path,body)) with sync_playwright() as p: @@ -38,7 +39,7 @@ with sync_playwright() as p: page.locator('#directoryNext').click();page.locator('#directoryTree').fill('INVALID NAME');page.locator('#directoryNext').click();assert 'zulässige' in page.locator('#directoryMessage').inner_text();page.locator('#directoryTree').fill('MARS_TREE');page.locator('#directoryNext').click();page.locator('#directoryAuto').click();page.locator('#directoryNext').click();assert 'Tree / Baum: leer lassen' in page.locator('#directoryClient').input_value();page.locator('#directorySave').click();page.wait_for_function("document.getElementById('directoryMessage').textContent.includes('gespeichert')");assert config['placements'] # A failed reload must not permit a save of stale data. fail=True;page.locator('#directoryBack').click();page.locator('#directoryBack').click();page.locator('#directoryBack').click();page.locator('#directoryReload').click();page.wait_for_function("document.getElementById('directoryMessage').textContent.includes('Bitte erneut laden')");assert page.locator('#directoryNext').is_disabled();fail=False;page.locator('#directoryReload').click();page.wait_for_function("!document.getElementById('directoryNext').disabled");page.locator('#directoryBindery').click();page.wait_for_function("document.getElementById('bindSummary').textContent.includes('2 Objekte')") - page.locator('#createUser').click();page.locator('[name=name]').fill('alice');page.get_by_role('button',name='Sicheres Kennwort erzeugen').click();pw=page.locator('[name=password]').input_value();assert len(pw)==20 and all(c in '0123456789ABCDEF' for c in pw);page.locator('#actionSubmit').click();page.wait_for_function("document.getElementById('bindSummary').textContent.includes('3 Objekte')");assert created==1;assert page.locator('[name=password]').input_value()=='' + page.locator('#createUser').click();page.locator('[name=name]').fill('alice');assert page.locator('[name=unix]').input_value()=='';page.locator('[name=unix]').select_option('chris');page.get_by_role('button',name='Sicheres Kennwort erzeugen').click();pw=page.locator('[name=password]').input_value();assert len(pw)==20 and all(c in '0123456789ABCDEF' for c in pw);page.locator('#actionSubmit').click();page.wait_for_function("document.getElementById('bindSummary').textContent.includes('3 Objekte')");assert created==1;assert page.locator('[name=password]').input_value()=='' page.evaluate("()=>document.querySelectorAll('dialog[open]').forEach(d=>d.close())") page.locator('#ncpIpOpen').click();page.wait_for_function("!document.getElementById('ncpPresetIp').disabled") page.locator('#ncpPresetIp').click();assert page.locator('#ncpIpEnabled').is_checked();assert page.locator('#ncpIpSlp').is_checked();assert page.locator('#ncpIpRestart').is_disabled() diff --git a/tests/test_local_mapping.c b/tests/test_local_mapping.c new file mode 100644 index 0000000..bc5fa89 --- /dev/null +++ b/tests/test_local_mapping.c @@ -0,0 +1,31 @@ +#define _GNU_SOURCE +#include "identity_api.h" +#include "identity.h" +#include +#include +#include +#include +#include +static char names[4][48],accounts[4][20];static int count,fail_create; +json_object *bindery_call(json_object *q){ + json_object *o=json_object_new_object();const char *op=js(q,"op"); + if(!strcmp(op,"identity-capabilities"))json_object_object_add(o,"identityVersion",json_object_new_int(1)); + else if(!strcmp(op,"objects")){json_object *a=json_object_new_array();for(int i=0;i0);json_object *u=json_object_array_get_idx(users,0);char account[20];snprintf(account,sizeof account,"%s",js(u,"name"));int uid=json_object_get_int(get(u,"uid")),gid=json_object_get_int(get(u,"gid"));json_object_put(r); + json_object *q=json_tokener_parse("{\"name\":\"ALICE\",\"password\":\"TESTPASS1\",\"sharedConfirmed\":true}");addstr(q,"unix","root");json_object_object_add(q,"uid",json_object_new_int(0));json_object_object_add(q,"gid",json_object_new_int(0));rejected(q); + addstr(q,"unix",account);json_object_object_add(q,"uid",json_object_new_int(uid+1));json_object_object_add(q,"gid",json_object_new_int(gid));rejected(q); + json_object_object_add(q,"uid",json_object_new_int(uid));json_object_object_add(q,"sharedConfirmed",json_object_new_boolean(0));rejected(q);json_object_object_add(q,"sharedConfirmed",json_object_new_boolean(1)); + r=identity_create(q);assert(!get(r,"error")&&count==1);assert(!strcmp(js(r,"unix"),account));json_object_put(r);assert(identity_local_managed("ALICE"));rejected(q); + addstr(q,"name","BOB");r=identity_create(q);assert(!get(r,"error")&&count==2);json_object_put(r);assert(!strcmp(accounts[0],accounts[1])); + r=identity_status();assert(json_object_array_length(get(r,"localMappings"))==2);assert(!strcmp(js(json_object_array_get_idx(get(r,"localMappings"),0),"status"),"linked"));assert(!strstr(json_object_to_json_string(r),"TESTPASS1"));json_object_put(r); + fail_create=1;addstr(q,"name","FAILED");rejected(q);assert(identity_local_managed("FAILED"));fail_create=0;rejected(q); + sqlite3 *db;assert(!mars_id_open(&db,1));assert(sqlite3_exec(db,"UPDATE local_mappings SET uid=uid+1 WHERE name='ALICE'",NULL,NULL,NULL)==SQLITE_OK);sqlite3_close(db); + r=identity_status();assert(!strcmp(js(json_object_array_get_idx(get(r,"localMappings"),0),"status"),"account-changed"));json_object_put(r); + json_object_put(q);unlink(MARS_ID_DB);puts("PASS SQL local mappings: root/stale ID rejection, explicit confirmation, shared account, duplicates, failed reservation, identity drift, no passwords"); +} diff --git a/websetup/app.js b/websetup/app.js index 35d2c41..ed9437f 100644 --- a/websetup/app.js +++ b/websetup/app.js @@ -64,8 +64,18 @@ $('bindRefresh').onclick=()=>task(refreshBindery);$('bindFilter').oninput=render const pwField={key:'password',label:'NetWare-Kennwort (8–63 Zeichen, Großbuchstaben/ASCII)',type:'password',netware:true}; function editObject(o){modal(o.name,[{key:'op',label:'Aktion',options:(o.type===1?['password','map-user','disable','enable','delete']:['delete']).map(value=>({value,label:{password:'Kennwort ändern', 'map-user':'Linux-Konto zuordnen (Experten)',disable:'Konto sperren',enable:'Konto entsperren',delete:'Endgültig löschen'}[value]}))}],'Bei Änderungen an bestehenden Konten ggf. nwserv.conf anpassen. Löschen ist endgültig.',async d=>{const params={name:o.name,type:o.type};if(d.op==='map-user'){setTimeout(()=>modal('Linux-Zuordnung: '+o.name,[{key:'unix',label:'Bestehender Linux-Benutzer (nicht root)'}],'Nur bei abgemeldetem Benutzer. Diese Änderung migriert keine Dateieigentümer. Bestehende Dateirechte können verloren gehen.',async v=>{await liveAPI('map-user',{...params,...v});await refreshBindery();}),0);return;}if(d.op==='password'){/* open password sheet after closing first */setTimeout(()=>modal('Kennwort: '+o.name,[pwField],'Nur NetWare-Kennwort; Linux bleibt unverändert.',async v=>{await liveAPI('password',{...params,...v});await refreshBindery();}),0);return;}if(d.op==='delete'&&!confirm(o.name+' endgültig löschen?'))return;await liveAPI(d.op,params);await refreshBindery();});} $('createLinuxUser').onclick=()=>modal('Benutzer mit bestehendem Linux-Konto anlegen',[{key:'name',label:'NetWare-Name (Großbuchstaben)'},{key:'unix',label:'Bestehendes Linux-Konto (nicht root)'},pwField],'Neues Objekt wird live angelegt und EVERYONE zugeordnet.',async d=>{await liveAPI('create-user',{...d,name:d.name.toUpperCase()});await refreshBindery();}); -$('createUser').onclick=()=>task(async()=>{const r=await api('/api/identities');if(!r.wrappedBindery||r.databaseError||!r.liveComplete||(r.issues||[]).some(i=>['uid-conflict','alias-conflict','mapping-invalid'].includes(i.code)))throw Error(r.databaseError||'Benutzeranlage derzeit nicht sicher möglich. Unter „Identitäten prüfen“ die Live-Bindery und mögliche Konflikte kontrollieren.');modal('NetWare-Benutzer anlegen (SQLite)',[{key:'name',label:'NetWare-Name (A–Z, 0–9, _ oder -)'},pwField],'Kein Linux-Konto nötig. MARS reserviert eine eigene UID/GID; das Kennwort bleibt in der NetWare-Bindery.',async d=>{const result=await api('/api/identities',{op:'create',name:d.name.toUpperCase(),password:d.password,confirm:true});notice('Benutzer angelegt: '+result.alias+' · UID '+result.uid);await refreshBindery();});}); -$('identityInspect').onclick=()=>task(async()=>{const r=await api('/api/identities');await refreshBindery();const status={linked:'Zugeordnet',reserved:'Reserviert (nicht wiederverwenden)',conflict:'Konflikt',unknown:'Nicht prüfbar'};const lines=[r.wrappedBindery?'SQLite-Adapter erkannt':'SQLite-Adapter fehlt: MARS neu bauen',r.databaseError||(r.databaseAvailable?'Datenbank lesbar':'Datenbank entsteht beim ersten Benutzer'),r.liveComplete?'Live-Bindery vollständig gelesen':'Live-Bindery nicht vollständig: Zustand unklar',r.truncated?'Liste auf 1000 Reservierungen begrenzt.':'',...(r.issues||[]).map(i=>'PRÜFEN: '+i.name+' – '+i.detail),...r.identities.map(i=>i.name+' · UID/GID '+i.uid+' · '+(status[i.status]||'Nicht prüfbar'))].filter(Boolean);modal('Benutzerverwaltung prüfen',[],lines.join('\n'),async()=>{});$('actionHint').classList.add('property-list');}); +$('createUser').onclick=()=>task(async()=>{ + const r=await api('/api/identities'); + if(!r.wrappedBindery||r.databaseError||!r.liveComplete||(r.issues||[]).some(i=>['uid-conflict','alias-conflict','mapping-invalid'].includes(i.code)))throw Error(r.databaseError||'Identitäten und Live-Bindery zuerst prüfen.'); + const users=r.localUsers||[];if(!users.length)throw Error('Kein geeignetes lokales Linux-Konto vorhanden (UID 1000–59999, Name höchstens 19 Zeichen). Ein normales Datenkonto auf Linux anlegen; root ist ausgeschlossen.'); + modal('SQL-Benutzer mit Linux-Konto anlegen',[{key:'name',label:'NetWare-Name (A–Z, 0–9, _ oder -)'},{key:'unix',label:'Linux-Konto für Dateizugriffe',options:[{value:'',label:'Bitte bewusst auswählen …'},...users.map(u=>({value:u.name,label:u.name+' · UID '+u.uid+' / GID '+u.gid}))]},pwField], + 'SQLite speichert die Zuordnung zum vorhandenen Linux-Konto. Dessen Dateirechte und Unix-Gruppen gelten; NetWare-Trustee-Rechte können zusätzlich einschränken. Mehrere MARS-Benutzer mit demselben Konto teilen die Unix-Dateirechte und den Dateieigentümer. Keine automatische Ordnerfreigabe, Rechteänderung oder Passwortsynchronisation mit Samba/Linux.',async d=>{ + const u=users.find(u=>u.name===d.unix);if(!u)throw Error('Linux-Konto auswählen.'); + if(!confirm('Dateizugriffe von '+d.name.toUpperCase()+' als Linux-Benutzer '+u.name+' ausführen? Andere darauf zugeordnete Benutzer teilen dieselben Unix-Dateirechte.'))throw Error('Anlage abgebrochen; nichts geändert.'); + const result=await api('/api/identities',{op:'create',name:d.name.toUpperCase(),password:d.password,unix:u.name,uid:u.uid,gid:u.gid,sharedConfirmed:true,confirm:true});notice('Benutzer angelegt: '+d.name.toUpperCase()+' → '+result.unix+' · UID '+result.uid);await refreshBindery(); + }); +}); +$('identityInspect').onclick=()=>task(async()=>{const r=await api('/api/identities');await refreshBindery();const status={linked:'Zugeordnet',reserved:'Reserviert (nicht wiederverwenden)',conflict:'Konflikt',unknown:'Nicht prüfbar'};const lines=[r.wrappedBindery?'SQLite-Adapter erkannt':'SQLite-Adapter fehlt: MARS neu bauen',r.databaseError||(r.databaseAvailable?'Datenbank lesbar':'Datenbank entsteht beim ersten Benutzer'),r.liveComplete?'Live-Bindery vollständig gelesen':'Live-Bindery nicht vollständig: Zustand unklar',r.truncated?'Liste auf 1000 Reservierungen begrenzt.':'',...(r.issues||[]).map(i=>'PRÜFEN: '+i.name+' – '+i.detail),...(r.localMappings||[]).map(i=>i.name+' → Linux '+i.unix+' · UID '+i.uid+' / GID '+i.gid+' · '+(status[i.status]||i.status)),...r.identities.map(i=>i.name+' · UID/GID '+i.uid+' · '+(status[i.status]||'Nicht prüfbar'))].filter(Boolean);modal('Benutzerverwaltung prüfen',[],lines.join('\n'),async()=>{});$('actionHint').classList.add('property-list');}); $('createGroup').onclick=()=>modal('Gruppe anlegen',[{key:'name',label:'NetWare-Gruppenname'}],'Live-Bindery',async d=>{await liveAPI('create-group',{name:d.name.toUpperCase()});await refreshBindery();}); $('membership').onclick=()=>modal('Gruppenzugehörigkeit',[{key:'name',label:'Benutzer',options:objects.filter(o=>o.type===1&&o.name!=='SUPERVISOR').map(o=>o.name)},{key:'group',label:'Gruppe',options:objects.filter(o=>o.type===2&&o.name!=='EVERYONE').map(o=>o.name)},{key:'op',label:'Aktion',options:['add-member','remove-member']}],'Benutzer vorher abmelden; alle drei NetWare-Mitgliedschaftseigenschaften werden gepflegt.',async d=>{await liveAPI(d.op,d);await refreshBindery();}); let printers=[];const jstates={3:'Wartend',4:'Angehalten',5:'Druckt',6:'Gestoppt',7:'Abgebrochen',8:'Fehler',9:'Abgeschlossen'}; diff --git a/websetup/index.html b/websetup/index.html index 7bf7302..7f851fa 100644 --- a/websetup/index.html +++ b/websetup/index.html @@ -14,7 +14,7 @@ - +
Freigaberechte

Originale Trustee-Rechte für einen Benutzer oder eine Gruppe. Alle NetWare-Verbindungen vor Änderungen trennen. Kein SYS, keine Home- oder Wechselvolumes.

Entfernen einer direkten Zuweisung ist kein explizites Verbot: vererbte Rechte und Unix-Rechte können weiterhin gelten.