Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fw32.git;a=commitdiff;h=481943b3d5f368259defd3fc88959985ea014985

commit 481943b3d5f368259defd3fc88959985ea014985
Author: James Buren <[email protected]>
Date:   Fri Jun 29 11:48:15 2012 -0500

fw32: when using fw32-run, fallback to home directory if cwd is not usable.

diff --git a/fw32.c b/fw32.c
index 51080af..6b45bcb 100644
--- a/fw32.c
+++ b/fw32.c
@@ -673,8 +673,9 @@ fw32_merge(char **args1)
static void
fw32_run(int i,char **args1)
{
-  char cwd[PATH_MAX];
+  char cwd[PATH_MAX], path[PATH_MAX], *dir;
struct passwd *pwd;
+  struct stat st;

if(!getcwd(cwd,sizeof cwd))
error("getcwd: %s\n",strerror(errno));
@@ -684,10 +685,14 @@ fw32_run(int i,char **args1)
if(!pwd)
error("Failed to retrieve password entry.\n");

+  snprintf(path,sizeof path,"%s%s",FW32_ROOT,cwd);
+
+  dir = stat(path,&st) ? pwd->pw_dir : cwd;
+
if(i < 1)
-    run(pwd->pw_shell,cwd,true,args1);
+    run(pwd->pw_shell,dir,true,args1);
else
-    run(args1[0],cwd,true,args1+1);
+    run(args1[0],dir,true,args1+1);
}

static void
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to