From 2320156cd51c6678236a32adfa1bac3952372857 Mon Sep 17 00:00:00 2001 From: Mikhail Zakharov Date: Sat, 7 Sep 2024 14:55:36 +0200 Subject: [PATCH] Release ts-warp-1.5.6 --- CHANGELOG.md | 3 ++- gui/ports/macOS/gui-warp.py | 22 +++++++++++++++++++++- gui/ports/macOS/starter.c | 17 ++++++++--------- version.h | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6979c0f..f72b5f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # CHANGELOG -* **2024.09.04 Current** +* **2024.09.07 ts-warp-1.5.6, gui-warp-1.0.25 (gui-warp-v1.0.32-mac), ns-warp-1.0.7**** + * `GUI-Warp.app`: Better handling of `starter`, `starter.c` updated to v1.3 * `GUI-Warp.app`: `starter.c` updated to v1.2 * `inifile.c`: `proxy_server` variable parsing. Thanks for the bug-hunting and testing * `GUI-Warp.app`: `starter.c` to handle environment variables diff --git a/gui/ports/macOS/gui-warp.py b/gui/ports/macOS/gui-warp.py index 9284565..01c244d 100644 --- a/gui/ports/macOS/gui-warp.py +++ b/gui/ports/macOS/gui-warp.py @@ -60,7 +60,7 @@ def __init__(self, width=800, height=560, self.password = '' - self.version = 'v1.0.31-mac' + self.version = 'v1.0.32-mac' self.width = width self.height = height @@ -357,12 +357,16 @@ def saveini(self, t_widget, filename): Save INI-file """ + uid = os.getuid() + gid = os.getgid() with open(filename, 'w', encoding='utf8') as f: f.write(t_widget.get('1.0', tk.END)[:-1]) # Strip extra newline + os.chown(filename, uid, gid) # Rebuild ts-warp_pf.conf when saving the INI-file with open(fwfile, 'w', encoding='utf8') as outfw: subprocess.run(['./ts-warp_autofw.sh', prefix], stdout=outfw, check=False) + os.chown(fwfile, uid, gid) # ---------------------------------------------------------------------------------------------------------------- # def pauselog(self, btn, txt, filename): @@ -432,7 +436,10 @@ def run_script(self, command): stdin=subprocess.PIPE) gwp.communicate(self.password) else: + uid = os.getuid() + os.setuid(0) subprocess.Popen([runcmd, command, prefix, '-v', self.cmb_lvl.get(), self.tsw_opts.get()]) + os.setreuid(uid, 0) # ---------------------------------------------------------------------------------------------------------------- # def ask_password(self): @@ -561,14 +568,27 @@ def dedupch(s, c='/'): os.makedirs(prefix + 'etc/') if not os.path.exists(prefix + 'var/log/'): os.makedirs(prefix + 'var/log/') + if not os.path.exists(logfile): + open(logfile, 'a').close() if not os.path.exists(prefix + 'var/run/'): os.makedirs(prefix + 'var/run/') + if not os.path.exists(pidfile): + open(pidfile, 'a').close() if not os.path.exists(prefix + 'var/spool/ts-warp/'): os.makedirs(prefix + 'var/spool/ts-warp/') + for f in (prefix, prefix + '/etc', prefix + '/var', prefix + 'var/log', prefix + 'var/run', + prefix + 'var/spool', prefix + 'var/spool/ts-warp', prefix + 'etc/gui-warp.ini', + runcmd, inifile, fwfile, logfile, pidfile, actfile): + try: + os.chown(f, os.getuid(), os.getgid()) + except: + pass + if not os.path.exists(fwfile): with open(fwfile, 'w', encoding='utf8') as outfw: subprocess.run(['./ts-warp_autofw.sh', prefix], stdout=outfw, check=False) + os.chown(fwfile, os.getuid(), os.getgid()) if not os.path.exists(logfile): open(logfile, 'a', encoding='utf8').close() diff --git a/gui/ports/macOS/starter.c b/gui/ports/macOS/starter.c index 6416914..676c8a3 100644 --- a/gui/ports/macOS/starter.c +++ b/gui/ports/macOS/starter.c @@ -9,10 +9,13 @@ this stuff is worth it, you can buy me a beer in return Mikhail Zakharov */ +/* -------------------------------------------------------------------------- */ + /* 2024.08.29 v1.0 Initial release 2024.09.01 v1.1 Handle environment variables - 2024.09.04 v1.2 Preserve original starter name for the started app + 2024.09.04 v1.2 Pass original starter name as the started app name + 2024.09.06 v1.3 Pass app args; allow app handling UID/EUID; Drop environ */ @@ -28,23 +31,19 @@ /* -------------------------------------------------------------------------- */ int main(int argc, char *argv[]) { - extern char** environ; char buf[DIRBUFSZ]; - if (argc > 2 || (argc == 2 && !strncmp(argv[1], "-h", 2))) { - fprintf(stdout, - "Run a program (default name: app) in the same directory\n\n" - "Usage: %s [program]\n", basename(argv[0])); + if (argc == 2 && !strncmp(argv[1], "-h", 2)) { + fprintf(stdout, "Run a program named app from the same directory\n"); return 0; } - setuid(geteuid()); - if (argv[0][0] == '/') strncpy(buf, dirname(argv[0]), DIRBUFSZ); else getcwd(buf, DIRBUFSZ); strncat(buf, APP_NAME, DIRBUFSZ); + argv[0] = basename(argv[0]); - return execle(buf, basename(argv[0]), 0, environ); + return execv(buf, argv); } diff --git a/version.h b/version.h index b5dea74..38c23ca 100644 --- a/version.h +++ b/version.h @@ -29,7 +29,7 @@ #define PROG_NAME_SHORT "TSW" #define PROG_VERSION_MAJOR "1" #define PROG_VERSION_MINOR "5" -#define PROG_VERSION_BUILD "5" +#define PROG_VERSION_BUILD "6" #define PROG_VERSION PROG_VERSION_MAJOR "." PROG_VERSION_MINOR "." PROG_VERSION_BUILD #define PROG_NAME_FULL PROG_NAME " " PROG_VERSION #define PROG_NAME_CODE PROG_NAME_SHORT PROG_VERSION