#include <libubox/blobmsg_json.h>
#include <libubus.h>
#include <signal.h>
+#include <sys/stat.h>
#include <rpcd/session.h>
#include <rpcd/uci.h>
int main(int argc, char **argv)
{
+ struct stat s;
const char *hangup;
const char *ubus_socket = NULL;
int ch;
}
}
+ if (stat("/var/run/rpcd", &s))
+ mkdir("/var/run/rpcd", 0700);
+
signal(SIGPIPE, SIG_IGN);
signal(SIGHUP, handle_signal);
signal(SIGUSR1, handle_signal);
}
snprintf(path, sizeof(path) - 1,
- "/tmp/.uci-rpc-%s", (char *)blobmsg_data(sid));
+ RPC_UCI_SAVEDIR_PREFIX "%s", blobmsg_get_string(sid));
uci_set_savedir(cursor, path);
}
{
char path[PATH_MAX];
- snprintf(path, sizeof(path) - 1, "/tmp/.uci-rpc-%s", ses->id);
+ snprintf(path, sizeof(path) - 1, RPC_UCI_SAVEDIR_PREFIX "%s", ses->id);
rpc_uci_purge_savedir(path);
}
/*
- * Removes all delta directories which match the /tmp/.uci-rpc-* pattern.
+ * Removes all delta directories which match the RPC_UCI_SAVEDIR_PREFIX.
* This is used to clean up garbage when starting rpcd.
*/
void rpc_uci_purge_savedirs(void)
int i;
glob_t gl;
- if (!glob("/tmp/.uci-rpc-*", 0, NULL, &gl))
+ if (!glob(RPC_UCI_SAVEDIR_PREFIX "*", 0, NULL, &gl))
{
for (i = 0; i < gl.gl_pathc; i++)
rpc_uci_purge_savedir(gl.gl_pathv[i]);