Lines 24-29
Link Here
|
24 |
#include <algorithm> |
24 |
#include <algorithm> |
25 |
#include "app.h" |
25 |
#include "app.h" |
26 |
#include "numlock.h" |
26 |
#include "numlock.h" |
|
|
27 |
#include "util.h" |
27 |
|
28 |
|
28 |
|
29 |
|
29 |
#ifdef HAVE_SHADOW |
30 |
#ifdef HAVE_SHADOW |
Lines 128-142
void User1Signal(int sig) {
Link Here
|
128 |
|
129 |
|
129 |
|
130 |
|
130 |
#ifdef USE_PAM |
131 |
#ifdef USE_PAM |
131 |
App::App(int argc, char** argv): |
132 |
App::App(int argc, char** argv) |
132 |
pam(conv, static_cast<void*>(&LoginPanel)){ |
133 |
: pam(conv, static_cast<void*>(&LoginPanel)), |
133 |
#else |
134 |
#else |
134 |
App::App(int argc, char** argv){ |
135 |
App::App(int argc, char** argv) |
|
|
136 |
: |
135 |
#endif |
137 |
#endif |
|
|
138 |
mcookiesize(32) // Must be divisible by 4 |
139 |
{ |
136 |
int tmp; |
140 |
int tmp; |
137 |
ServerPID = -1; |
141 |
ServerPID = -1; |
138 |
testing = false; |
142 |
testing = false; |
139 |
mcookie = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; |
143 |
mcookie = string(App::mcookiesize, 'a'); |
140 |
daemonmode = false; |
144 |
daemonmode = false; |
141 |
force_nodaemon = false; |
145 |
force_nodaemon = false; |
142 |
firstlogin = true; |
146 |
firstlogin = true; |
Lines 1127-1139
string App::findValidRandomTheme(const string& set)
Link Here
|
1127 |
name = name.substr(0, name.length() - 1); |
1131 |
name = name.substr(0, name.length() - 1); |
1128 |
} |
1132 |
} |
1129 |
|
1133 |
|
1130 |
srandom(getpid()+time(NULL)); |
1134 |
Util::srandom(Util::makeseed()); |
1131 |
|
1135 |
|
1132 |
vector<string> themes; |
1136 |
vector<string> themes; |
1133 |
string themefile; |
1137 |
string themefile; |
1134 |
Cfg::split(themes, name, ','); |
1138 |
Cfg::split(themes, name, ','); |
1135 |
do { |
1139 |
do { |
1136 |
int sel = random() % themes.size(); |
1140 |
int sel = Util::random() % themes.size(); |
1137 |
|
1141 |
|
1138 |
name = Cfg::Trim(themes[sel]); |
1142 |
name = Cfg::Trim(themes[sel]); |
1139 |
themefile = string(THEMESDIR) +"/" + name + THEMESFILE; |
1143 |
themefile = string(THEMESDIR) +"/" + name + THEMESFILE; |
Lines 1160-1192
void App::replaceVariables(string& input,
Link Here
|
1160 |
} |
1164 |
} |
1161 |
|
1165 |
|
1162 |
|
1166 |
|
|
|
1167 |
/* |
1168 |
* We rely on the fact that all bits generated by Util::random() |
1169 |
* are usable, so we are taking full words from its output. |
1170 |
*/ |
1163 |
void App::CreateServerAuth() { |
1171 |
void App::CreateServerAuth() { |
1164 |
/* create mit cookie */ |
1172 |
/* create mit cookie */ |
1165 |
int i, r; |
1173 |
uint16_t word; |
1166 |
int hexcount = 0; |
1174 |
uint8_t hi, lo; |
1167 |
string authfile; |
1175 |
int i; |
1168 |
string cmd; |
1176 |
string authfile; |
1169 |
const char *digits = "0123456789abcdef"; |
1177 |
const char *digits = "0123456789abcdef"; |
1170 |
srand( time(NULL) ); |
1178 |
Util::srandom(Util::makeseed()); |
1171 |
for ( i = 0; i < 31; i++ ) { |
1179 |
for (i = 0; i < App::mcookiesize; i+=4) { |
1172 |
r = rand()%16; |
1180 |
word = Util::random() & 0xffff; |
1173 |
mcookie[i] = digits[r]; |
1181 |
lo = word & 0xff; |
1174 |
if (r>9) |
1182 |
hi = word >> 8; |
1175 |
hexcount++; |
1183 |
mcookie[i] = digits[lo & 0x0f]; |
|
|
1184 |
mcookie[i+1] = digits[lo >> 4]; |
1185 |
mcookie[i+2] = digits[hi & 0x0f]; |
1186 |
mcookie[i+3] = digits[hi >> 4]; |
1176 |
} |
1187 |
} |
1177 |
/* MIT-COOKIE: even occurrences of digits and hex digits */ |
|
|
1178 |
if ((hexcount%2) == 0) { |
1179 |
r = rand()%10; |
1180 |
} else { |
1181 |
r = rand()%5+10; |
1182 |
} |
1183 |
mcookie[31] = digits[r]; |
1184 |
/* reinitialize auth file */ |
1188 |
/* reinitialize auth file */ |
1185 |
authfile = cfg->getOption("authfile"); |
1189 |
authfile = cfg->getOption("authfile"); |
1186 |
remove(authfile.c_str()); |
1190 |
remove(authfile.c_str()); |
1187 |
putenv(StrConcat("XAUTHORITY=", authfile.c_str())); |
1191 |
putenv(StrConcat("XAUTHORITY=", authfile.c_str())); |
1188 |
cmd = cfg->getOption("xauth_path") + " -q -f " + authfile + " add :0 . " + mcookie; |
1192 |
Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"), |
1189 |
system(cmd.c_str()); |
1193 |
authfile); |
1190 |
} |
1194 |
} |
1191 |
|
1195 |
|
1192 |
char* App::StrConcat(const char* str1, const char* str2) { |
1196 |
char* App::StrConcat(const char* str1, const char* str2) { |