mirror of
https://github.com/team-infusion-developers/android_hardware_samsung.git
synced 2024-11-06 21:55:41 +00:00
macloader: Use fchmod() to change permissions.
Change-Id: I18bca9b022dba24403867b022af9d858aad72bc4 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
parent
2b601794d7
commit
7f517d761b
1 changed files with 12 additions and 10 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
|
@ -164,12 +165,19 @@ int main() {
|
|||
ALOGE("Can't write to %s\n", CID_PATH);
|
||||
return -1;
|
||||
}
|
||||
fclose(cidfile);
|
||||
|
||||
/* set permissions on cid file */
|
||||
ALOGD("Setting permissions on %s\n", CID_PATH);
|
||||
/* Change permissions of cid file */
|
||||
ALOGD("Change permissions of %s\n", CID_PATH);
|
||||
|
||||
fd = fileno(cidfile);
|
||||
amode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
||||
ret = chmod(CID_PATH, amode);
|
||||
ret = fchmod(fd, amode);
|
||||
fclose(cidfile);
|
||||
if (ret != 0) {
|
||||
ALOGE("Can't set permissions on %s - %s\n",
|
||||
CID_PATH, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
char* chown_cmd = (char*) malloc(strlen("chown system ") + strlen(CID_PATH) + 1);
|
||||
char* chgrp_cmd = (char*) malloc(strlen("chgrp system ") + strlen(CID_PATH) + 1);
|
||||
|
@ -178,12 +186,6 @@ int main() {
|
|||
system(chown_cmd);
|
||||
system(chgrp_cmd);
|
||||
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "chmod() on file %s failed\n", CID_PATH);
|
||||
ALOGE("Can't set permissions on %s\n", CID_PATH);
|
||||
return ret;
|
||||
}
|
||||
|
||||
} else {
|
||||
/* delete cid file if no specific type */
|
||||
ALOGD("Deleting file %s\n", CID_PATH);
|
||||
|
|
Loading…
Reference in a new issue