forked from AeroNotix/slim-git
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=529306 Signed-off-by: Nobuhiro Iwamatsu <[email protected]>
- Loading branch information
iwamatsu
committed
Oct 16, 2009
1 parent
8a79846
commit 56c17be
Showing
9 changed files
with
136 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,8 @@ class App { | |
|
||
std::string themeName; | ||
std::string mcookie; | ||
|
||
const int mcookiesize; | ||
}; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* SLiM - Simple Login Manager | ||
Copyright (C) 2009 Eygene Ryabinkin <[email protected]> | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
*/ | ||
|
||
#include <sys/types.h> | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <time.h> | ||
#include <unistd.h> | ||
|
||
#include "util.h" | ||
|
||
/* | ||
* Adds the given cookie to the specified Xauthority file. | ||
* Returns true on success, false on fault. | ||
*/ | ||
bool Util::add_mcookie(const std::string &mcookie, const char *display, | ||
const std::string &xauth_cmd, const std::string &authfile) | ||
{ | ||
FILE *fp; | ||
std::string cmd = xauth_cmd + " -f " + authfile + " -q"; | ||
|
||
fp = popen(cmd.c_str(), "w"); | ||
if (!fp) | ||
return false; | ||
fprintf(fp, "remove %s\n", display); | ||
fprintf(fp, "add %s %s %s\n", display, ".", mcookie.c_str()); | ||
fprintf(fp, "exit\n"); | ||
|
||
pclose(fp); | ||
return true; | ||
} | ||
|
||
/* | ||
* Interface for random number generator. Just now it uses ordinary | ||
* random/srandom routines and serves as a wrapper for them. | ||
*/ | ||
void Util::srandom(unsigned long seed) | ||
{ | ||
::srandom(seed); | ||
} | ||
|
||
long Util::random(void) | ||
{ | ||
return ::random(); | ||
} | ||
|
||
/* | ||
* Makes seed for the srandom() using "random" values obtained from | ||
* getpid(), time(NULL) and others. | ||
*/ | ||
long Util::makeseed(void) | ||
{ | ||
struct timespec ts; | ||
long pid = getpid(); | ||
long tm = time(NULL); | ||
|
||
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { | ||
ts.tv_sec = ts.tv_nsec = 0; | ||
} | ||
|
||
return pid + tm + (ts.tv_sec ^ ts.tv_nsec); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* SLiM - Simple Login Manager | ||
Copyright (C) 2009 Eygene Ryabinkin <[email protected]> | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
*/ | ||
#ifndef __UTIL_H__ | ||
#define __UTIL_H__ | ||
|
||
#include <string> | ||
|
||
namespace Util { | ||
bool add_mcookie(const std::string &mcookie, const char *display, | ||
const std::string &xauth_cmd, const std::string &authfile); | ||
|
||
void srandom(unsigned long seed); | ||
long random(void); | ||
|
||
long makeseed(void); | ||
}; | ||
|
||
#endif /* __UTIL_H__ */ |