Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libsignon-qt5] Initialize secrets db on start. Fixes JB#34557
- Loading branch information
Marko Kenttälä
committed
Nov 7, 2018
1 parent
91ed876
commit 8bbfaf4
Showing
5 changed files
with
69 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
TEMPLATE = app | ||
CONFIG += console | ||
CONFIG -= app_bundle | ||
CONFIG -= qt | ||
TARGET = signon-storage-perm | ||
|
||
INCLUDEPATH += ../src ../lib | ||
SOURCES += signon-storage-perm.c | ||
|
||
target.path = $${INSTALL_PREFIX}/usr/libexec | ||
|
||
INSTALLS += target |
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,44 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <error.h> | ||
#include <errno.h> | ||
#include <unistd.h> | ||
#include <pwd.h> | ||
#include <sys/stat.h> | ||
|
||
#include <stdbool.h> | ||
#include "signond/signond-common.h" | ||
|
||
#define PATH_LEN 256 | ||
#define PRIVILEGED_USER "privileged" | ||
|
||
int main() | ||
{ | ||
char path[PATH_LEN]; | ||
// Get user home dir | ||
struct passwd *pwd = getpwuid(getuid()); | ||
if (!pwd) { | ||
error(ENOENT, ENOENT, "User id %d not found", getuid()); | ||
} | ||
if ((strlen(pwd->pw_dir) + strlen(signonDefaultStoragePath)) > PATH_LEN) { | ||
error(ENAMETOOLONG, ENAMETOOLONG, "File name too long"); | ||
} | ||
strcpy(path, pwd->pw_dir); | ||
// Skip the first ~ char | ||
strcat(path, &signonDefaultStoragePath[1]); | ||
|
||
// Get privileged user id and group | ||
pwd = getpwnam(PRIVILEGED_USER); | ||
if (!pwd) { | ||
error(ENOENT, ENOENT, "User %s not found", PRIVILEGED_USER); | ||
} | ||
|
||
// Set permissions | ||
if (chown(path, pwd->pw_uid, pwd->pw_gid)) { | ||
perror("chown"); | ||
} | ||
if (chmod(path, 0770)) { | ||
perror("chmod"); | ||
} | ||
return 0; | ||
} |
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