Skip to content

Commit

Permalink
GUI-Warp.app: starter.c updated to v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mezantrop committed Sep 4, 2024
1 parent c0a9c97 commit c618de2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

* **2024.09.01 Current**
* **2024.09.04 Current**
* `GUI-Warp.app`: `starter.c` updated to v1.2
* `inifile.c`: `proxy_server` variable parsing. Thanks <jesussanchezvalle@gmail.com> for the bug-hunting and testing
* `GUI-Warp.app`: `starter.c` to handle environment variables
* `minmiconf`: Updated to version `1.1.1.0`
Expand Down
24 changes: 11 additions & 13 deletions gui/ports/macOS/starter.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,41 @@
*/

/*
2024.08.29 v1.0 Initial release
2024.09.01 v1.1 Handle environment variables
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
*/


/* -------------------------------------------------------------------------- */
#include <stdio.h>
#include <libgen.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

/* -------------------------------------------------------------------------- */
#define APP_NAME "app"
#define DIRBUFSZ 256
#define APP_NAME "/app"
#define DIRBUFSZ 256

/* -------------------------------------------------------------------------- */
int main(int argc, char *argv[]) {
extern char** environ;
char buf[DIRBUFSZ];
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"
"Run a program (default name: app) in the same directory\n\n"
"Usage: %s [program]\n", basename(argv[0]));
return 0;
return 0;
}

setuid(geteuid());

if (argv[0][0] == '/')
strncpy(buf, dirname(argv[0]), DIRBUFSZ);
else
else
getcwd(buf, DIRBUFSZ);
sprintf(buf + strnlen(buf, DIRBUFSZ), "/%s", APP_NAME);
strncat(buf, APP_NAME, DIRBUFSZ);

return execle(buf, APP_NAME, 0, environ);
return execle(buf, basename(argv[0]), 0, environ);
}

0 comments on commit c618de2

Please sign in to comment.