X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Frtapelib.c;h=a31a8930c912cffca617ac4e9f9e2c294983c70a;hb=9038410bb75854bcb5c4f5a9b360a17b6e6d57f8;hp=38036aee92b58482b42bbd3fabdf3bd54e02ff1e;hpb=2bda83b48d8a6807632312403561b11b79048443;p=chaz%2Ftar diff --git a/src/rtapelib.c b/src/rtapelib.c index 38036ae..a31a893 100644 --- a/src/rtapelib.c +++ b/src/rtapelib.c @@ -88,8 +88,10 @@ static int from_remote[MAXUNIT][2] = {{-1, -1}, {-1, -1}, {-1, -1}, {-1, -1}}; /* The pipes for sending data to remote tape drives. */ static int to_remote[MAXUNIT][2] = {{-1, -1}, {-1, -1}, {-1, -1}, {-1, -1}}; +#define RMT_COMMAND (rmt_command_option ? rmt_command_option : "/etc/rmt") + /* Temporary variable used by macros in rmt.h. */ -char *rmt_path__; +char *rmt_dev_name__; /* Close remote tape connection HANDLE, and reset errno to ERRNO_VALUE. */ @@ -289,7 +291,7 @@ _rmt_rexec (char *host, char *user) if (rexecserv = getservbyname ("exec", "tcp"), !rexecserv) error (EXIT_ON_EXEC_ERROR, 0, _("exec/tcp: Service not available")); - result = rexec (&host, rexecserv->s_port, user, 0, "/etc/rmt", 0); + result = rexec (&host, rexecserv->s_port, user, 0, RMT_COMMAND, 0); if (fclose (stdin) == EOF) error (0, errno, _("stdin")); fdopen (saved_stdin, "r"); @@ -346,15 +348,16 @@ encode_oflag (char *buf, int oflag) } /* Open a file (a magnetic tape device?) on the system specified in - PATH, as the given user. PATH has the form `[USER@]HOST:FILE'. + FILE_NAME, as the given user. FILE_NAME has the form `[USER@]HOST:FILE'. OPEN_MODE is O_RDONLY, O_WRONLY, etc. If successful, return the remote pipe number plus BIAS. REMOTE_SHELL may be overridden. On error, return -1. */ int -rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) +rmt_open__ (const char *file_name, int open_mode, int bias, + const char *remote_shell) { int remote_pipe_number; /* pseudo, biased file descriptor */ - char *path_copy ; /* copy of path string */ + char *file_name_copy; /* copy of file_name string */ char *remote_host; /* remote host name */ char *remote_file; /* remote file name (often a device) */ char *remote_user; /* remote user name */ @@ -379,21 +382,21 @@ rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) { char *cursor; - path_copy = xstrdup (path); - remote_host = path_copy; + file_name_copy = xstrdup (file_name); + remote_host = file_name_copy; remote_user = 0; remote_file = 0; - for (cursor = path_copy; *cursor; cursor++) + for (cursor = file_name_copy; *cursor; cursor++) switch (*cursor) { default: break; case '\n': - /* Do not allow newlines in the path, since the protocol + /* Do not allow newlines in the file_name, since the protocol uses newline delimiters. */ - free (path_copy); + free (file_name_copy); errno = ENOENT; return -1; @@ -429,7 +432,7 @@ rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) if (READ_SIDE (remote_pipe_number) < 0) { int e = errno; - free (path_copy); + free (file_name_copy); errno = e; return -1; } @@ -448,7 +451,7 @@ rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) #ifdef REMOTE_SHELL remote_shell = REMOTE_SHELL; #else - free (path_copy); + free (file_name_copy); errno = EIO; return -1; #endif @@ -461,7 +464,7 @@ rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) || pipe (from_remote[remote_pipe_number]) == -1) { int e = errno; - free (path_copy); + free (file_name_copy); errno = e; return -1; } @@ -470,7 +473,7 @@ rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) if (status == -1) { int e = errno; - free (path_copy); + free (file_name_copy); errno = e; return -1; } @@ -493,10 +496,10 @@ rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) if (remote_user) execl (remote_shell, remote_shell_basename, remote_host, - "-l", remote_user, "/etc/rmt", (char *) 0); + "-l", remote_user, RMT_COMMAND, (char *) 0); else execl (remote_shell, remote_shell_basename, remote_host, - "/etc/rmt", (char *) 0); + RMT_COMMAND, (char *) 0); /* Bad problems if we get here. */ @@ -524,14 +527,14 @@ rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) { int e = errno; free (command_buffer); - free (path_copy); + free (file_name_copy); _rmt_shutdown (remote_pipe_number, e); return -1; } free (command_buffer); } - free (path_copy); + free (file_name_copy); return remote_pipe_number + bias; }