summaryrefslogtreecommitdiffstats
path: root/options.c
diff options
context:
space:
mode:
authorPeter Schlaile2009-10-08 10:36:06 +0200
committerroot2009-10-08 10:36:06 +0200
commit320159175adced71da64efa80e9334f7bcab96c8 (patch)
tree31598c8832ced9b02fc5e450e6717412113f8ac6 /options.c
parentDon't detect tones for SS5, if the minimum noise level is not reached. (diff)
downloadlcr-320159175adced71da64efa80e9334f7bcab96c8.tar.gz
lcr-320159175adced71da64efa80e9334f7bcab96c8.tar.xz
lcr-320159175adced71da64efa80e9334f7bcab96c8.zip
added owner / group options to options.conf
makes the usual setup LCR running as "root" and asterisk running as "asterisk" easier to configure.
Diffstat (limited to 'options.c')
-rw-r--r--options.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/options.c b/options.c
index 6f74533..f58d7f9 100644
--- a/options.c
+++ b/options.c
@@ -17,6 +17,8 @@
#include "macro.h"
#include "extension.h"
#include "options.h"
+#include <grp.h>
+#include <pwd.h>
struct options options = {
"/usr/local/lcr/log", /* log file */
@@ -31,6 +33,8 @@ struct options options = {
"lcr@your.machine", /* source mail adress */
"/var/tmp", /* path of lock files */
0700, /* rights of lcr admin socket */
+ -1, /* socket user (-1= no change) */
+ -1, /* socket group (-1= no change) */
0 /* enable gsm */
};
@@ -202,6 +206,30 @@ int read_options(void)
SCPY(options.lock, param);
} else
+ if (!strcmp(option,"socketuser")) {
+ char * endptr = NULL;
+ options.socketuser = strtol(param, &endptr, 10);
+ if (*endptr != '\0') {
+ struct passwd * pwd = getpwnam(param);
+ if (pwd == NULL) {
+ SPRINT(options_error, "Error in %s (line %d): no such user: %s.\n",filename,line,param);
+ goto error;
+ }
+ options.socketuser = pwd->pw_uid;
+ }
+ } else
+ if (!strcmp(option,"socketgroup")) {
+ char * endptr = NULL;
+ options.socketgroup = strtol(param, &endptr, 10);
+ if (*endptr != '\0') {
+ struct group * grp = getgrnam(param);
+ if (grp == NULL) {
+ SPRINT(options_error, "Error in %s (line %d): no such group: %s.\n",filename,line,param);
+ goto error;
+ }
+ options.socketgroup = grp->gr_gid;
+ }
+ } else
if (!strcmp(option,"socketrights")) {
options.socketrights = strtol(param, NULL, 0);
} else