summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
69fd5e0)
You may change the path of socket and lock files.
LCR admin socket's flags can now be altered to allow access to other users.
Lock and socket files will now be removed when terminating LCR.
modified: Makefile
modified: chan_lcr.c
modified: default/options.conf
modified: lcradmin.c
modified: lcrsocket.h
modified: main.c
modified: options.c
modified: options.h
modified: socket_server.c
trace.o \
$(LIBS) -o $(LCR)
trace.o \
$(LIBS) -o $(LCR)
-$(LCRADMIN): lcradmin.c cause.c *.h Makefile
+$(LCRADMIN): lcradmin.c cause.c options.c *.h Makefile
$(PP) $(LIBDIR) $(CFLAGS_LCRADMIN) $(CURSES) -lm lcradmin.c cause.c \
$(PP) $(LIBDIR) $(CFLAGS_LCRADMIN) $(CURSES) -lm lcradmin.c cause.c \
+ options.c -o $(LCRADMIN)
$(CHAN_LCR): chan_lcr.o bchannel.o callerid.o options.o *.h Makefile
$(CC) -shared -Xlinker -x $(LDFLAGS) -o $(CHAN_LCR) chan_lcr.o bchannel.o callerid.o options.o
$(CHAN_LCR): chan_lcr.o bchannel.o callerid.o options.o *.h Makefile
$(CC) -shared -Xlinker -x $(LDFLAGS) -o $(CHAN_LCR) chan_lcr.o bchannel.o callerid.o options.o
int open_socket(void)
{
int ret;
int open_socket(void)
{
int ret;
- char *socket_name = SOCKET_NAME;
int conn;
struct sockaddr_un sock_address;
unsigned int on = 1;
int conn;
struct sockaddr_un sock_address;
unsigned int on = 1;
/* set socket address and name */
memset(&sock_address, 0, sizeof(sock_address));
sock_address.sun_family = PF_UNIX;
/* set socket address and name */
memset(&sock_address, 0, sizeof(sock_address));
sock_address.sun_family = PF_UNIX;
- strcpy(sock_address.sun_path, socket_name);
+ sprintf(sock_address.sun_path, SOCKET_NAME, options.lock);
/* connect socket */
if ((conn = connect(lcr_sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0)
/* connect socket */
if ((conn = connect(lcr_sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0)
# Most mail servers require an existing domain in order to accept mails.
#email lcr@your.domain
# Most mail servers require an existing domain in order to accept mails.
#email lcr@your.domain
+# Directory to write lock file and admin socket file to.
+# If /var/run does not have the rights to run LCR, you may choose /var/tmp
+# or any directory with the appropiet rights LCR runs with.
+#lock /var/run
+
+# Change rights of LCR socket, where lcradmin or chan_lcr connects to.
+# By default 700 (user only) rights are set. If Asterisk runs with a different
+# user, the rights may be changed to all users (777).
+# Rights must have 0 in front, if octal values above are used.
+#socketrights 0700
+
#include <errno.h>
#include <curses.h>
#include "macro.h"
#include <errno.h>
#include <curses.h>
#include "macro.h"
#include "join.h"
#include "joinpbx.h"
#include "extension.h"
#include "join.h"
#include "joinpbx.h"
#include "extension.h"
int main(int argc, char *argv[])
{
int mode;
int main(int argc, char *argv[])
{
int mode;
- char *socket_name = SOCKET_NAME;
int sock, conn;
struct sockaddr_un sock_address;
char *ret;
int sock, conn;
struct sockaddr_un sock_address;
char *ret;
+ if (read_options() == 0) {
+ exit(EXIT_FAILURE);
+ }
+
//pipeagain:
/* open socket */
if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
//pipeagain:
/* open socket */
if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
exit(EXIT_FAILURE);
}
memset(&sock_address, 0, sizeof(sock_address));
exit(EXIT_FAILURE);
}
memset(&sock_address, 0, sizeof(sock_address));
+ SPRINT(sock_address.sun_path, SOCKET_NAME, options.lock);
sock_address.sun_family = PF_UNIX;
sock_address.sun_family = PF_UNIX;
- UCPY(sock_address.sun_path, socket_name);
if ((conn = connect(sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0)
{
close(sock);
if ((conn = connect(sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0)
{
close(sock);
** **
\*****************************************************************************/
** **
\*****************************************************************************/
-#define SOCKET_NAME "/var/run/LCR.socket"
+#define SOCKET_NAME "%s/LCR.socket"
/* structures that define message between admin-tool and pbx */
/* structures that define message between admin-tool and pbx */
created_lock = 0, created_signal = 0, created_debug = 0,
created_misdn = 0;
int idletime = 0, idlecheck = 0;
created_lock = 0, created_signal = 0, created_debug = 0,
created_misdn = 0;
int idletime = 0, idlecheck = 0;
+ char tracetext[256], lock[128];
}
/* create lock and lock! */
}
/* create lock and lock! */
- if ((lockfd = open("/var/run/lcr.lock", O_CREAT, 0)) < 0)
+ SPRINT(lock, "%s/lcr.lock", options.lock);
+ if ((lockfd = open(lock, O_CREAT | O_WRONLY)) < 0)
- fprintf(stderr, "Cannot create lock file: /var/run/lcr.lock\n");
+ fprintf(stderr, "Cannot create lock file: %s\n", lock);
+ fprintf(stderr, "Check options.conf to change to path with permissions for you.\n");
goto free;
}
if (flock(lockfd, LOCK_EX|LOCK_NB) < 0)
goto free;
}
if (flock(lockfd, LOCK_EX|LOCK_NB) < 0)
switch(errno)
{
case ENOMEM:
switch(errno)
{
case ENOMEM:
- fprintf(stderr, "Not enough memory to lock paging, exitting...\n");
+ fprintf(stderr, "Warning: Not enough memory to lock paging, exitting...\n");
- fprintf(stderr, "No permission to lock paging, exitting...\n");
+ fprintf(stderr, "Warning: No permission to lock paging, exitting...\n");
- fprintf(stderr, "'Bad address' while locking paging, exitting...\n");
+ fprintf(stderr, "Warning: 'Bad address' while locking paging, exitting...\n");
- fprintf(stderr, "Unknown error %d while locking paging, exitting...\n", errno);
+ fprintf(stderr, "Warning: Unknown error %d while locking paging, exitting...\n", errno);
}
/* set real time scheduler & priority */
}
/* set real time scheduler & priority */
if (created_lock)
flock(lockfd, LOCK_UN);
if (lockfd >= 0)
if (created_lock)
flock(lockfd, LOCK_UN);
if (lockfd >= 0)
+ {
+ chmod(lock, 0700);
+ unlink(lock);
/* free rulesets */
if (ruleset_first)
/* free rulesets */
if (ruleset_first)
"", /* dummy caller id */
0, /* use tones by dsp.o */
0, /* by default use priority 0 */
"", /* dummy caller id */
0, /* use tones by dsp.o */
0, /* by default use priority 0 */
- "lcr@your.machine" /* source mail adress */
+ "lcr@your.machine", /* source mail adress */
+ "/var/tmp", /* path of lock files */
+ 0700 /* rights of lcr admin socket */
};
char options_error[256];
};
char options_error[256];
SCPY(options.email, param);
} else
SCPY(options.email, param);
} else
+ if (!strcmp(option,"lock"))
+ {
+ if (param[0]==0)
+ {
+ SPRINT(options_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
+ goto error;
+ }
+ if (param[strlen(param)-1] == '/')
+ param[strlen(param)-1]=0;
+ SCPY(options.lock, param);
+
+ } else
+ if (!strcmp(option,"socketrights"))
+ {
+ options.socketrights = strtol(param, NULL, 0);
+ } else
{
SPRINT(options_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);
goto error;
{
SPRINT(options_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);
goto error;
int dsptones; /* tones will be generated via dsp.o 1=american 2=ger */
int schedule; /* run process in realtime @ given priority */
char email[128]; /* source email address */
int dsptones; /* tones will be generated via dsp.o 1=american 2=ger */
int schedule; /* run process in realtime @ given priority */
char email[128]; /* source email address */
+ char lock[128]; /* path of lock files */
+ int socketrights; /* rights of lcr admin socket */
};
extern struct options options;
};
extern struct options options;
-char *socket_name = SOCKET_NAME;
int sock = -1;
struct sockaddr_un sock_address;
int sock = -1;
struct sockaddr_un sock_address;
}
fhuse++;
memset(&sock_address, 0, sizeof(sock_address));
}
fhuse++;
memset(&sock_address, 0, sizeof(sock_address));
+ SPRINT(socket_name, SOCKET_NAME, options.lock);
sock_address.sun_family = AF_UNIX;
UCPY(sock_address.sun_path, socket_name);
unlink(socket_name);
sock_address.sun_family = AF_UNIX;
UCPY(sock_address.sun_path, socket_name);
unlink(socket_name);
PERROR("Failed to set socket \"%s\" into non-blocking mode. (errno=%d)\n", sock_address.sun_path, errno);
return(-1);
}
PERROR("Failed to set socket \"%s\" into non-blocking mode. (errno=%d)\n", sock_address.sun_path, errno);
return(-1);
}
+ if (chmod(socket_name, options.socketrights) < 0)
+ {
+ PERROR("Failed to change socket rigts to %d. (errno=%d)\n", options.socketrights, errno);
+ }