I'd like to set a script to execute on the remote
machine before mounting occurs. (eg to set a clearcase
view on the remote machine) Could you add a command
line option for specifying a local or remote script to
execute prior to mounting? Maybe I'm missing something?
Logged In: NO
this patch should do it. PLease try it out and I will
submit it:
--- shfsmount.c.orig 2004-08-12 19:13:09.000000000 -0700
+++ shfsmount.c 2004-08-12 23:53:22.000000000 -0700
@@ -68,6 +68,12 @@ static char *cmd_template = NULL;
/* command to execute */
static char *cmd = NULL;
+/* script to run before mounting*/
+static char *script = NULL;
+
+/* buffer to hold script command*/
+static char *script_buf = NULL;
+
/* user (& group) under the cmd is executed */
static uid_t cmd_uid = 0;
static gid_t cmd_gid = 0;
@@ -134,6 +140,7 @@ usage(FILE *fp, int res)
" uid=USER\towner of all files/dirs on
mounted filesystem (root only)\n"
" gid=GROUP\tgroup of all files/dirs on
mounted filesystem (root only)\n"
" rmode=MODE\troot dir mode (default is 700)\n"
+ " script=SCRIPT\texecute this script on the
remote server before mount\n"
" suid, dev\tsee mount(8) (root only)\n"
" ro, rw, nosuid, nodev, exec, noexec,
user, users: see mount(8)\n"
" cmd-user, cmd, port, persistent, type,
stable: see above\n\n"
@@ -506,6 +513,10 @@ main(int argc, char **argv)
snprintf(buf, sizeof(buf), "user=%s", pw->pw_name);
strnconcat(options, sizeof(options), ",", buf, NULL);
}
+ } else if (!strncmp(s,
"script=", 7)) {
+ snprintf(buf, sizeof(buf),
"%s", s+7);
+ script =
malloc(strlen(buf)+1);
+ strcpy(script,buf);
} else {
strnconcat(options,
sizeof(options), ",", s, NULL);
}
@@ -581,6 +592,40 @@ main(int argc, char **argv)
strnconcat(options, sizeof(options), buf, NULL);
}
+ if (script){
+ pid_t new_pid;
+ new_pid =fork();
+ switch(new_pid)
+ {
+ case 0:
+ script_buf = malloc(BUFFER_MAX);
+ if (!script_buf)
+ error("Insufficient memory");
+ snprintf(script_buf, BUFFER_MAX, "ssh %s%s
%s%s %s %s",
+ port ? "-p " : "", port ? port : "",
+ user ? "-l " : "", user ? user : "",
+ host, script);
+ VERBOSE("script: %s\n", script_buf);
+
+
+ if (have_uid){
+ setuid(cmd_uid);
+ }
+
+ execl(script_buf,0);
+ break;
+ case -1:
+ /*error*/
+ break;
+ default:
+ {
+ pid_t child_pid;
+ int stat_val;
+ child_pid = wait(&stat_val);
+ }
+ }
+ }
+
/* setup cmd */
cmd = malloc(BUFFER_MAX);
if (!cmd)
@@ -625,6 +670,9 @@ main(int argc, char **argv)
VERBOSE("cmd: %s, options: \"%s\"\n", cmd, options);
VERBOSE("user: %s, host: %s, root: %s, mnt: %s,
port: %s, cmd-user: %d\n", user, host, root, mnt, port,
cmd_uid);
+
+
+
if (persistent)
daemonize();
@@ -671,3 +719,13 @@ main(int argc, char **argv)
exit(res);
}
+
+
+
+
+
+
+
+
+
+
Logged In: YES
user_id=660343
Would you please attach the patch as a file? Cutting and
pasting isn't working. It generates errors due to extra new
line characters.
Thanks,
Eric
Logged In: YES
user_id=660343
never mind I manually applied the changes.
Working on testing it.
-E