Bazaar/SysExec : remove a couple of obsolete files

git-svn-id: svn://ultimatepp.org/upp/trunk@3056 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
micio 2011-01-21 19:04:33 +00:00
parent 2b05af9537
commit 87919d1abb
2 changed files with 0 additions and 200 deletions

View file

@ -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 "<NULL>";
Buffer<char *>buf(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 == "<NULL>")
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;
}

View file

@ -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