Skip to content

Commit d33a048

Browse files
committed
login: Use alternative for getlogin_r (#26)
1 parent 6423b67 commit d33a048

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

login/login.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <cryptopp/rijndael.h>
55
#include <gtk/gtk.h>
66
#include <iostream>
7+
#include <pwd.h>
78
#include <string>
89
#include <webkit2/webkit2.h>
910

@@ -16,12 +17,11 @@ typedef unsigned char byte;
1617
void getEncryptionKey(unsigned char *key, int size) {
1718
unsigned char s_entropy[16] = {200, 118, 244, 174, 76, 149, 46, 254,
1819
242, 250, 15, 84, 25, 192, 156, 67};
19-
char name[16];
20-
getlogin_r(name, sizeof(name));
2120

22-
int length = strlen(name);
21+
struct passwd *pwd = getpwuid(getuid());
22+
int length = strlen(pwd->pw_name);
2323
for (int i = 0; i < length; i++) {
24-
s_entropy[i] ^= name[i];
24+
s_entropy[i] ^= pwd->pw_name[i];
2525
}
2626

2727
unsigned char salt[] = {'s', 'o', 'm', 'e', 'S', 'a', 'l', 't'};

0 commit comments

Comments
 (0)