char arch[ARCH_MAX];
char keystore_path[PATH_MAX];
+ uid_t uid;
int flags;
// Lock
if (!pakfire_on_root(pakfire))
return 0;
+ // We must be root in order to operate in /
+ if (pakfire->uid) {
+ ERROR(pakfire, "Must be running as root on /\n");
+ errno = EPERM;
+ return 1;
+ }
+
if (strcmp(pakfire->distro.id, "ipfire") != 0) {
ERROR(pakfire, "Not an IPFire system\n");
errno = EPERM;
return 1;
}
- // Check if we are running as root
- uid_t uid = getuid();
- if (uid != 0) {
- errno = EPERM;
- return 1;
- }
-
struct pakfire* p = calloc(1, sizeof(*p));
if (!p)
return 1;
p->nrefs = 1;
p->flags = flags;
+ // Store the UID we are running as
+ p->uid = getuid();
+
// Set architecture
pakfire_string_set(p->arch, arch);