Introduction
Introduction Statistics Contact Development Disclaimer Help
Make sure to normalize path names for B. - sam - An updated version of the sam …
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
commit 0677cef74fe4031e029131682a14838337d046c1
parent 993a6b58e56e8a35a2834220ff552325814180ba
Author: Rob King <[email protected]>
Date: Tue, 10 Jan 2017 10:03:00 -0600
Make sure to normalize path names for B.
Diffstat:
sam/sam.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/sam/sam.c b/sam/sam.c
@@ -1,9 +1,14 @@
/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
+/* Copyright (c) 2016 Rob King */
+
+#define _XOPEN_SOURCE 500
#include "sam.h"
#include <libgen.h>
+#include <limits.h>
#include <signal.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -111,8 +116,18 @@ bmain(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (getbsocketname(machine) == NULL)
- return fputs("could not determine controlling socket name\n", stderr),…
+ if (getbsocketname(machine) == NULL){
+ argc += optind;
+ argv -= optind;
+
+ char *nargv[argc + 1];
+ fputs("could not determine controlling socket name, starting new insta…
+ nargv[0] = "sam";
+ for (int i = 1; i < argc; i++)
+ nargv[i] = argv[i];
+ nargv[argc] = NULL;
+ execvp("sam", nargv);
+ }
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
@@ -122,8 +137,13 @@ bmain(int argc, char *argv[])
strncat(cmd, "B ", B_CMD_MAX);
for (int i = 0; i < argc; i++){
- strncat(cmd, " ", B_CMD_MAX);
- strncat(cmd, argv[i], B_CMD_MAX);
+ char path[FILENAME_MAX + 1];
+ if (realpath(argv[i], path) == NULL)
+ perror(argv[i]);
+ else{
+ strncat(cmd, " ", B_CMD_MAX);
+ strncat(cmd, path, B_CMD_MAX);
+ }
}
strncat(cmd, "\n", B_CMD_MAX);
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.