LOG(log_debug, logtype_default,"ad_conv_v22ea_hf(\"%s\"): deleting adouble:v2 file: \"%s\"",
path, fullpathname(adpath));
-// become_root();
+ become_root();
EC_ZERO_LOG( unlink(adpath) );
-// unbecome_root();
+ unbecome_root();
EC_CLEANUP:
LOG(log_debug, logtype_default,"ad_convert(\"%s\"): END: %d", fullpathname(path), ret);
mktemp(eaname);
-// become_root();
+ become_root();
if ((sys_setxattr(vol->v_path, eaname, eacontent, 4, 0)) == 0) {
sys_removexattr(vol->v_path, eaname);
haseas = 0;
}
-// unbecome_root();
+ unbecome_root();
return haseas;
}
static uid_t saved_uid = -1;
+/*
+ * seteuid(0) and back, if either fails and panic != 0 we PANIC
+ */
void become_root(void)
{
- saved_uid = geteuid();
- if (seteuid(0) != 0)
- AFP_PANIC("Can't seteuid(0)");
+ if (getuid() == 0) {
+ saved_uid = geteuid();
+ if (seteuid(0) != 0)
+ AFP_PANIC("Can't seteuid(0)");
+ }
}
void unbecome_root(void)
{
- if (saved_uid == -1 || seteuid(saved_uid) < 0)
- AFP_PANIC("Can't seteuid back");
- saved_uid = -1;
+ if (getuid() == 0) {
+ if (saved_uid == -1 || seteuid(saved_uid) < 0)
+ AFP_PANIC("Can't seteuid back");
+ saved_uid = -1;
+ }
}
/*!