fixed problems with PWD - we no longer use the PWD env variable
authorAndrew Tridgell <tridge@samba.org>
Fri, 23 Oct 1998 01:27:23 +0000 (01:27 +0000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 23 Oct 1998 01:27:23 +0000 (01:27 +0000)
instead the shared variable area is used.

this fixes problems with /bin/sh under solaris
(This used to be commit 4eb7b5c6a81447755dfa1be27479027333ed6f26)

source3/smbwrapper/smbsh.c
source3/smbwrapper/smbw.c
source3/smbwrapper/smbw.h

index b677707741a92d2bff9a4a67432515de408efb30..8c9d00bd98134f7b0b2ba302ee3dd925617587ff 100644 (file)
@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
 {
        char *p, *u;
        char *libd = BINDIR;    
-       pstring line;
+       pstring line, wd;
        int opt;
        extern char *optarg;
        extern int optind;
@@ -91,9 +91,11 @@ int main(int argc, char *argv[])
 
        smbw_setenv("PS1", "smbsh$ ");
 
-       sys_getwd(line);
+       sys_getwd(wd);
 
-       smbw_setenv("PWD", line);
+       slprintf(line,sizeof(line)-1,"PWD_%d", getpid());
+
+       smbw_setshared(line, wd);
 
        slprintf(line,sizeof(line)-1,"%s/smbwrapper.so", libd);
        smbw_setenv("LD_PRELOAD", line);
index 23b5c9a9c7b450ba8518958c240406df24901ca9..c09d7509f059a91e7ee706854c69b5d27665a9c7 100644 (file)
@@ -50,6 +50,7 @@ void smbw_init(void)
        extern FILE *dbf;
        char *p;
        int eno;
+       pstring line;
 
        if (initialised) return;
        initialised = 1;
@@ -96,13 +97,16 @@ void smbw_init(void)
                DEBUG(2,("SMBW_PREFIX is %s\n", smbw_prefix));
        }
 
-       if ((p=getenv(SMBW_PWD_ENV))) {
-               pstrcpy(smbw_cwd, p);
-               DEBUG(4,("Initial cwd from smbw_cwd is %s\n", smbw_cwd));
-       } else {
-               sys_getwd(smbw_cwd);
-               DEBUG(4,("Initial cwd from getwd is %s\n", smbw_cwd));
+       slprintf(line,sizeof(line)-1,"PWD_%d", getpid());
+       
+       p = smbw_getshared(line);
+       if (!p) {
+               DEBUG(0,("ERROR: %s is not set\n", line));
+               exit(1);
        }
+       pstrcpy(smbw_cwd, p);
+       DEBUG(4,("Initial cwd is %s\n", smbw_cwd));
+
        smbw_busy--;
 
        set_maxfiles(SMBW_MAX_OPEN);
@@ -1325,6 +1329,7 @@ int smbw_fork(void)
        pid_t child;
        int p[2];
        char c=0;
+       pstring line;
 
        struct smbw_file *file, *next_file;
        struct smbw_server *srv, *next_srv;
@@ -1356,6 +1361,9 @@ int smbw_fork(void)
                smbw_srv_close(srv);
        }
 
+       slprintf(line,sizeof(line)-1,"PWD_%d", getpid());
+       smbw_setshared(line,smbw_cwd);
+
        /* unblock the parent */
        write(p[1], &c, 1);
        close(p[1]);
index 8de5b5776a07b61c7e49cc353adbf844bf0cfced..7241f8b3c55d370ff6c1e609de9e85d8980562e1 100644 (file)
@@ -28,8 +28,6 @@
 #define SMBW_FILE_MODE (S_IFREG | 0444)
 #define SMBW_DIR_MODE (S_IFDIR | 0555)
 
-#define SMBW_PWD_ENV "PWD"
-
 struct smbw_server {
        struct smbw_server *next, *prev;
        struct cli_state cli;