### Required packages
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1 libtzplatform-config)
+pkg_check_modules(pkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1 libtzplatform-config libsmack)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-pkg_check_modules(libpkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1 libtzplatform-config)
+pkg_check_modules(libpkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1 libtzplatform-config libsmack)
FOREACH(flag ${libpkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/smack.h>
#include <sys/stat.h>
#include <unistd.h>
#include <db-util.h>
return 0;
}
-static int parserdb_change_perm(const char *db_file)
+static int parserdb_change_perm(const char *db_file, uid_t uid)
{
char buf[BUFSIZE];
char journal_file[BUFSIZE];
_LOGD("getgrnam(users) returns NULL !");
}
for (i = 0; files[i]; i++) {
- ret = chown(files[i], OWNER_ROOT, (gid_t)grpinfo->gr_gid);
+ ret = chown(files[i], uid, (gid_t)grpinfo->gr_gid);
if (ret == -1) {
strerror_r(errno, buf, sizeof(buf));
- _LOGD("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, grpinfo->gr_gid, buf);
+ _LOGD("FAIL : chown %s %d.%d, because %s", db_file, uid, grpinfo->gr_gid, buf);
return -1;
}
_LOGD("FAIL : chmod %s 0664, because %s", db_file, buf);
return -1;
}
+ /* chsmack */
+ if(smack_setlabel(db_file, "_", SMACK_LABEL_ACCESS))
+ {
+ _LOGE("failed chsmack -a \"_\" %s", db_file);
+ } else {
+ _LOGD("chsmack -a \"_\" %s", db_file);
+ }
}
return 0;
return -1;
}
if(uid != GLOBAL_USER) {
- if( 0 != parserdb_change_perm(getUserPkgParserDBPathUID(uid))) {
+ if( 0 != parserdb_change_perm(getUserPkgParserDBPathUID(uid), uid)) {
_LOGD("Failed to change permission\n");
}
}
return -1;
}
if(uid != GLOBAL_USER) {
- if( 0 != parserdb_change_perm(getUserPkgCertDBPathUID(uid))) {
+ if( 0 != parserdb_change_perm(getUserPkgCertDBPathUID(uid), uid)) {
_LOGD("Failed to change permission\n");
}
}