From 87919d1abbc2f7f6b4fd6d366ce96c6e9fd6fba1 Mon Sep 17 00:00:00 2001 From: micio Date: Fri, 21 Jan 2011 19:04:33 +0000 Subject: [PATCH] Bazaar/SysExec : remove a couple of obsolete files git-svn-id: svn://ultimatepp.org/upp/trunk@3056 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/SysExec/Xauth.cpp | 138 ------------------------------------- bazaar/SysExec/execvpe.cpp | 62 ----------------- 2 files changed, 200 deletions(-) delete mode 100644 bazaar/SysExec/Xauth.cpp delete mode 100644 bazaar/SysExec/execvpe.cpp diff --git a/bazaar/SysExec/Xauth.cpp b/bazaar/SysExec/Xauth.cpp deleted file mode 100644 index 590f105d1..000000000 --- a/bazaar/SysExec/Xauth.cpp +++ /dev/null @@ -1,138 +0,0 @@ -static String GetXauthToken(String const &disp) -{ - String bin; - - // find xauth binary executable - if(FileExists("/usr/bin/xauth")) - bin = "/usr/bin/xauth"; - else if(FileExists("/usr/X11R6/bin/xauth")) - bin = "/usr/X11R6/bin/xauth"; - else - return ""; - - // executes it and get token from its output - FILE *xauthOutput = popen(FormatString("%s list %s | head -1 | awk '{ print $3 }'", bin, disp), "r"); - if(!xauthOutput) - return ""; - Bufferbuf(256); - fread(buf, sizeof(char), 255, xauthOutput); - pclose(xauthOutput); - - // return token - return buf; -} - -static bool PrepareXauth(String &disp, String &token) -{ - disp = Environment().Get("DISPLAY", ""); - token = GetXauthToken(disp); - if(token == "") - return false; - // if empty token, try to get it stripping the hostname - // part from DISPLAY environment var - if(token == "") - { - int i = disp.ReverseFind(':'); - if(i >= 0) - { - disp = disp.Mid(i); - token = GetXauthToken(disp); - } - } - return true; -} - - - -static gboolean sudo_prepare_xauth (GksuContext *context) -{ - gchar template[] = "/tmp/" PACKAGE "-XXXXXX"; - gboolean error_copying = FALSE; - gchar *xauth = NULL; - - context->dir = g_strdup (mkdtemp(template)); - - if (!context->dir) - { - fprintf (stderr, strerror(errno)); - return FALSE; - } - - xauth = g_strdup(g_getenv ("XAUTHORITY")); - - if (xauth == NULL) - xauth = g_strdup_printf ("%s/.Xauthority", g_get_home_dir()); - - error_copying = !copy (xauth, context->dir); - - g_free (xauth); - - if (error_copying) - return FALSE; - - return TRUE; -} - - - - -static gboolean copy (const char *fn, const char *dir) -{ - int in, out; - int r; - char *newfn; - char buf[BUFSIZ] = ""; - - newfn = g_strdup_printf("%s/.Xauthority", dir); - - out = open(newfn, O_WRONLY | O_CREAT | O_EXCL, 0600); - - if (out == -1) - { - if (errno == EEXIST) - fprintf (stderr, - "Impossible to create the .Xauthority file: a file " - "already exists. This might be a security issue; " - "please investigate."); - else - fprintf (stderr, - "Error copying '%s' to '%s': %s", - fn, dir, strerror(errno)); - - return FALSE; - } - - in = open(fn, O_RDONLY); - - if (in == -1) - { - fprintf (stderr, - "Error copying '%s' to '%s': %s", - fn, dir, strerror(errno)); - return FALSE; - } - - while ((r = read(in, buf, BUFSIZ)) > 0) - { - if (full_write(out, buf, r) == -1) - { - fprintf (stderr, - "Error copying '%s' to '%s': %s", - fn, dir, strerror(errno)); - return FALSE; - } - } - - if (r == -1) - { - fprintf (stderr, - "Error copying '%s' to '%s': %s", - fn, dir, strerror(errno)); - return FALSE; - } - - return TRUE; -} - - - diff --git a/bazaar/SysExec/execvpe.cpp b/bazaar/SysExec/execvpe.cpp deleted file mode 100644 index a0adb297f..000000000 --- a/bazaar/SysExec/execvpe.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////// -// this one is let here just for reference -- superseded by linux builtin call -#if 0 - -#define DEFAULT_PATH "/bin:/usr/bin:." -static int execvpe(const char *file, char * const *argv, char * const *envp) -{ - char path[PATH_MAX]; - const char *searchpath, *esp; - size_t prefixlen, filelen, totallen; - - if (strchr(file, '/')) /* Specific path */ - return execve(file, argv, envp); - - filelen = strlen(file); - - searchpath = getenv("PATH"); - if (!searchpath) - searchpath = DEFAULT_PATH; - - errno = ENOENT; /* Default errno, if execve() doesn't change it */ - - do - { - esp = strchr(searchpath, ':'); - if (esp) - prefixlen = esp - searchpath; - else - prefixlen = strlen(searchpath); - - if (prefixlen == 0 || searchpath[prefixlen-1] == '/') - { - totallen = prefixlen + filelen; - if (totallen >= PATH_MAX) - continue; - memcpy(path, searchpath, prefixlen); - memcpy(path + prefixlen, file, filelen); - } - else - { - totallen = prefixlen + filelen + 1; - if (totallen >= PATH_MAX) - continue; - memcpy(path, searchpath, prefixlen); - path[prefixlen] = '/'; - memcpy(path + prefixlen + 1, file, filelen); - } - path[totallen] = '\0'; - - execve(path, argv, envp); - if (errno == E2BIG || errno == ENOEXEC || - errno == ENOMEM || errno == ETXTBSY) - break; /* Report this as an error, no more search */ - - searchpath = esp + 1; - } - while (esp); - - return -1; -} -#endif -