Commit 770d3699 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Try to get the VSM ownership right.

The general rule is that if varnishd is started as root, you need
to be root or in group "varnish" to access the shared memory.

Fixes	#2419
parent 2aeca565
......@@ -166,7 +166,6 @@ void mgt_SHM_static_alloc(const void *, ssize_t size,
void mgt_SHM_Create(void);
void mgt_SHM_Destroy(int keep);
extern struct vsmw *mgt_vsmw;
void mgt_SHM_ChildNew(void);
void mgt_SHM_ChildDestroy(void);
......
......@@ -504,9 +504,9 @@ mgt_cli_secret(const char *S_arg)
char buf[BUFSIZ];
/* Save in shmem */
VJ_master(JAIL_MASTER_FILE);
mgt_SHM_static_alloc(S_arg, strlen(S_arg) + 1L, "Arg", "-S");
VJ_master(JAIL_MASTER_FILE);
fd = open(S_arg, O_RDONLY);
if (fd < 0) {
fprintf(stderr, "Can not open secret-file \"%s\"\n", S_arg);
......@@ -574,9 +574,7 @@ mgt_cli_telnet(const char *T_arg)
if (VSB_len(vsb) == 0)
ARGV_ERR("-T %s could not be listened on.\n", T_arg);
/* Save in shmem */
VJ_master(JAIL_MASTER_FILE);
mgt_SHM_static_alloc(VSB_data(vsb), VSB_len(vsb) + 1, "Arg", "-T");
VJ_master(JAIL_MASTER_LOW);
VSB_destroy(&vsb);
}
......
......@@ -839,10 +839,8 @@ main(int argc, char * const *argv)
mgt_SHM_Init();
VJ_master(JAIL_MASTER_FILE);
mgt_SHM_static_alloc(i_arg, strlen(i_arg) + 1L, "Arg", "-i");
VSC_C_mgt = VSC_mgt_New("");
VJ_master(JAIL_MASTER_LOW);
if (M_arg != NULL)
mgt_cli_master(M_arg);
......
......@@ -47,7 +47,7 @@
#include "vsm_priv.h"
#include "vsmw.h"
struct vsmw *mgt_vsmw;
static struct vsmw *mgt_vsmw;
/*--------------------------------------------------------------------
*/
......@@ -90,13 +90,16 @@ mgt_shm_atexit(void)
void
mgt_SHM_Init(void)
{
int fd;
VJ_master(JAIL_MASTER_FILE);
AZ(system("rm -rf " VSM_MGT_DIRNAME));
AZ(mkdir(VSM_MGT_DIRNAME, 0755));
mgt_vsmw = VSMW_New(open(VSM_MGT_DIRNAME, O_RDONLY), 0640, "_.index");
AN(mgt_vsmw);
fd = open(VSM_MGT_DIRNAME, O_RDONLY);
VJ_fix_vsm_dir(fd);
VJ_master(JAIL_MASTER_LOW);
mgt_vsmw = VSMW_New(fd, 0640, "_.index");
AN(mgt_vsmw);
proc_vsmw = mgt_vsmw;
......@@ -119,7 +122,6 @@ mgt_SHM_ChildNew(void)
MCH_Fd_Inherit(heritage.vsm_fd, "VSMW");
VJ_master(JAIL_MASTER_FILE);
heritage.param = VSMW_Allocf(mgt_vsmw, VSM_CLASS_PARAM,
sizeof *heritage.param, "");
AN(heritage.param);
......@@ -129,7 +131,6 @@ mgt_SHM_ChildNew(void)
heritage.panic_str = VSMW_Allocf(mgt_vsmw, "Panic",
heritage.panic_str_len, "");
AN(heritage.panic_str);
VJ_master(JAIL_MASTER_LOW);
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment