From: Camm Maguire Date: Sat, 4 Sep 2021 19:23:26 +0000 (+0100) Subject: X-Git-Tag: archive/raspbian/2.6.12-103+rpi1^2~26 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2b5f1f6c20ac29f581c370ef0f6583611c62330c;p=gcl.git TODO: Put a short summary on the line above and replace this paragraph with a longer explanation of this change. Complete the meta-information with other relevant fields (see below for details). To make it easier, the information below has been extracted from the changelog. Adjust it or drop it. gcl (2.6.12-78) unstable; urgency=medium * rebuild against latest compilers and tools * Version_2_6_13pre69 Gbp-Pq: Name Version_2_6_13pre70 --- diff --git a/h/linux.h b/h/linux.h index 474f7f31..3c94d8dc 100644 --- a/h/linux.h +++ b/h/linux.h @@ -132,17 +132,10 @@ do { int c = 0; \ #include #include -#define GET_FULL_PATH_SELF(a_) do { \ - static char q[PATH_MAX]; \ - const char *s="/proc/self/exe"; \ - struct stat ss; \ - if (stat(s,&ss)) \ - (a_)=argv[0]; \ - else { \ - if (!realpath(s,q)) \ - error("realpath error"); \ - (a_)=q; \ - } \ +#define GET_FULL_PATH_SELF(a_) do { \ + static char q[PATH_MAX]; \ + massert(which("/proc/self/exe",q) || which(argv[0],q)); \ + (a_)=q; \ } while(0) diff --git a/o/main.c b/o/main.c index de77f741..e9dda787 100755 --- a/o/main.c +++ b/o/main.c @@ -460,18 +460,49 @@ DEFUN_NEW("EQUAL-TAIL-RECURSION-CHECK",object,fSequal_tail_recursion_check,SI,1, RETURN1((object)(w-u)); } +static int +mbin(const char *s,char *o) { + + struct stat ss; + + if (!stat(s,&ss) && (ss.st_mode&S_IFMT)==S_IFREG && !access(s,R_OK|X_OK)) { + massert(realpath(s,o)); + return 1; + } + + return 0; + +} + +static int +which(const char *n,char *o) { + + char *s; + + if (strchr(n,'/')) + return mbin(n,o); + + massert(snprintf(FN1,sizeof(FN1),"%s",getenv("PATH"))>1); + for (s=NULL;(s=strtok(s ? NULL : FN1,":"));) { + + massert(snprintf(FN2,sizeof(FN2),"%s/%s",s,n)); + if (mbin(FN2,o)) + return 1; + + } + + return 0; + +} + + int main(int argc, char **argv, char **envp) { -#ifdef GET_FULL_PATH_SELF GET_FULL_PATH_SELF(kcl_self); -#else - kcl_self = argv[0]; -#endif - *argv=kcl_self; - + #ifdef CAN_UNRANDOMIZE_SBRK #include #include