sdb_close(fd);
}
+#define GRANT_FILE "/opt/share/askuser_disable"
+int grantfile_exist = 0;
+// TODO remove debug codes (snprintf buf)
+void handle_grantfile(int fd, void *cookie) {
+ char buf[2] = { 0, };
+ int opcode = atoi((char*)cookie);
+ char* tmppath = NULL;
+
+ if (opcode == 1) { // create
+ tmppath = realpath(GRANT_FILE, NULL);
+ if (tmppath == NULL && errno == ENOENT) {
+ grantfile_exist = 0;
+ FILE *f = fopen(GRANT_FILE, "w");
+
+ if (f != NULL) {
+ fclose(f);
+ snprintf(buf, sizeof(buf), "%s", " ");
+ } else {
+ D("sdbd: cannot create %s file, errno %d.\n", GRANT_FILE, errno);
+ snprintf(buf, sizeof(buf), "%s", "5");
+ }
+ } else {
+ grantfile_exist = 1;
+ D("sdbd: %s file is already existed.\n", GRANT_FILE);
+ snprintf(buf, sizeof(buf), "%s", "3");
+ free(tmppath);
+ }
+ } else if (opcode == 2) { // remove
+ if (grantfile_exist != 0) {
+ D("sdbd: %s file is already existed.\n", GRANT_FILE);
+ snprintf(buf, sizeof(buf), "%s", "4");
+ } else {
+ tmppath = realpath(GRANT_FILE, NULL);
+ if (tmppath == NULL && errno == ENOENT) {
+ D("sdbd: cannot find %s file.\n", GRANT_FILE);
+ snprintf(buf, sizeof(buf), "%s", "6");
+ } else if (tmppath != NULL && !strncmp(GRANT_FILE, tmppath, strlen(GRANT_FILE)+1)) {
+ sdb_unlink(GRANT_FILE);
+ snprintf(buf, sizeof(buf), "%s", " ");
+ free(tmppath);
+ } else {
+ D("sdbd: unknown error has occured.\n");
+ snprintf(buf, sizeof(buf), "%s", "8");
+ if (tmppath != NULL) {
+ free(tmppath);
+ }
+ }
+ }
+ } else {
+ // abnormal operation
+ D("sdbd: abnormal operation.\n");
+ snprintf(buf, sizeof(buf), "%s", "9");
+ }
+ writex(fd, buf, strlen(buf));
+ sdb_close(fd);
+}
+
int service_to_fd(const char *name)
{
int ret = -1;
char* env_variable = NULL;
env_variable = strdup(name+14);
ret = create_service_thread(get_tzplatform_env, (void *)(env_variable));
+ } else if(!strncmp(name, "grantfile:", 10)){
+ ret = create_service_thread(handle_grantfile, (void*)name+10);
} else if(!strncmp(name, "appcmd:", 7)){
ret = request_appcmd_to_plugin(name+7);
}