summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-03-24 20:45:01 +0100
committerJustus Winter <justus@gnupg.org>2016-04-17 17:08:26 +0200
commit6ff6261bb8b2bcf419689fdae4b68f6114f014a3 (patch)
tree82d9888b14f0a3f241442c5d133f5cd2f53fc021 /utils
parentf5e6769c33723a1d4b72722eff8bb68245ca3803 (diff)
utils/settrans: add option to specify the underlying node
* utils/settrans.c (options): Add '--underlying'. (main): Handle new option. (open_node): Open the node if given.
Diffstat (limited to 'utils')
-rw-r--r--utils/settrans.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/utils/settrans.c b/utils/settrans.c
index 399bd128..e01906b4 100644
--- a/utils/settrans.c
+++ b/utils/settrans.c
@@ -64,6 +64,8 @@ static struct argp_option options[] =
{"exclusive", 'x', 0, 0, "Only set the translator if there is not one already"},
{"orphan", 'o', 0, 0, "Disconnect old translator from the filesystem "
"(do not ask it to go away)"},
+ {"underlying", 'U', "NODE", 0, "Open NODE and hand it to the translator "
+ "as the underlying node"},
{"chroot", 'C', 0, 0,
"Instead of setting the node's translator, take following arguments up to"
@@ -157,6 +159,7 @@ main(int argc, char *argv[])
char *pid_file = NULL;
int excl = 0;
int timeout = DEFAULT_TIMEOUT * 1000; /* ms */
+ char *underlying_node_name = NULL;
char **chroot_command = 0;
char *chroot_chdir = "/";
@@ -202,6 +205,11 @@ main(int argc, char *argv[])
break;
case 'o': orphan = 1; break;
+ case 'U':
+ underlying_node_name = strdup (arg);
+ if (underlying_node_name == NULL)
+ error(3, ENOMEM, "Failed to duplicate argument");
+ break;
case 'C':
if (chroot_command)
@@ -330,7 +338,20 @@ main(int argc, char *argv[])
return open_err;
}
- *underlying = node;
+ if (underlying_node_name)
+ {
+ *underlying = file_name_lookup (underlying_node_name,
+ flags | lookup_flags, 0666);
+ if (! MACH_PORT_VALID (*underlying))
+ {
+ /* For the error message. */
+ node_name = underlying_node_name;
+ open_err = errno;
+ return open_err;
+ }
+ }
+ else
+ *underlying = node;
*underlying_type = MACH_MSG_TYPE_COPY_SEND;
return 0;