diff mbox

[2/5] package/redis: Add redis system user

Message ID 1437483774-30291-2-git-send-email-martin@barkynet.com
State Changes Requested
Headers show

Commit Message

Martin Bark July 21, 2015, 1:02 p.m. UTC
Add a redis system user and set the home directory to /var/lib/redis

Signed-off-by: Martin Bark <martin@barkynet.com>
---
 package/redis/redis.mk | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Thomas Petazzoni July 21, 2015, 1:27 p.m. UTC | #1
Dear Martin Bark,

On Tue, 21 Jul 2015 14:02:51 +0100, Martin Bark wrote:
> Add a redis system user and set the home directory to /var/lib/redis
> 
> Signed-off-by: Martin Bark <martin@barkynet.com>
> ---
>  package/redis/redis.mk | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/package/redis/redis.mk b/package/redis/redis.mk
> index 51c1f9c..633d411 100644
> --- a/package/redis/redis.mk
> +++ b/package/redis/redis.mk
> @@ -9,6 +9,10 @@ REDIS_SITE = http://download.redis.io/releases
>  REDIS_LICENSE = BSD-3c (core); MIT and BSD family licenses (Bundled components)
>  REDIS_LICENSE_FILES = COPYING
>  
> +define REDIS_USERS
> +	redis -1 redis -1 * /var/lib/redis /bin/sh - Redis Server

Does it really need to have a login shell?

> +endef
> +
>  # Redis doesn't support DESTDIR (yet, see
>  # https://github.com/antirez/redis/pull/609).  We set PREFIX
>  # instead.
> @@ -22,6 +26,7 @@ endef
>  define REDIS_INSTALL_TARGET_CMDS
>  	$(TARGET_MAKE_ENV) $(MAKE) $(REDIS_BUILDOPTS) -C $(@D) \
>  		LDCONFIG=true install
> +	$(INSTALL) -d -m 0700 $(TARGET_DIR)/var/lib/redis

I don't think this line is needed, unless you want to install specific
things to /var/lib/redis, since specifying /var/lib/redis for the
REDIS_USERS is sufficient to get this directory created and chown-ed to
the right user.

Best regards,

Thomas
Martin Bark July 21, 2015, 2:27 p.m. UTC | #2
Thomas,

On 21 July 2015 at 14:27, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Martin Bark,
>
> On Tue, 21 Jul 2015 14:02:51 +0100, Martin Bark wrote:
>> Add a redis system user and set the home directory to /var/lib/redis
>>
>> Signed-off-by: Martin Bark <martin@barkynet.com>
>> ---
>>  package/redis/redis.mk | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/package/redis/redis.mk b/package/redis/redis.mk
>> index 51c1f9c..633d411 100644
>> --- a/package/redis/redis.mk
>> +++ b/package/redis/redis.mk
>> @@ -9,6 +9,10 @@ REDIS_SITE = http://download.redis.io/releases
>>  REDIS_LICENSE = BSD-3c (core); MIT and BSD family licenses (Bundled components)
>>  REDIS_LICENSE_FILES = COPYING
>>
>> +define REDIS_USERS
>> +     redis -1 redis -1 * /var/lib/redis /bin/sh - Redis Server
>
> Does it really need to have a login shell?
>

It's because in the sysv script S50redis i shutdown redis using this command

    su - redis -c '/usr/bin/redis-cli shutdown'

I copied this idea from the postgresql package.  I guess i could just do

  /usr/bin/redis-cli shutdown

and run the command as root.  I'll investigate changing the login
shell to /bin/false

>> +endef
>> +
>>  # Redis doesn't support DESTDIR (yet, see
>>  # https://github.com/antirez/redis/pull/609).  We set PREFIX
>>  # instead.
>> @@ -22,6 +26,7 @@ endef
>>  define REDIS_INSTALL_TARGET_CMDS
>>       $(TARGET_MAKE_ENV) $(MAKE) $(REDIS_BUILDOPTS) -C $(@D) \
>>               LDCONFIG=true install
>> +     $(INSTALL) -d -m 0700 $(TARGET_DIR)/var/lib/redis
>
> I don't think this line is needed, unless you want to install specific
> things to /var/lib/redis, since specifying /var/lib/redis for the
> REDIS_USERS is sufficient to get this directory created and chown-ed to
> the right user.

Yes good point.  I'll remove that line and resubmit.

Thanks

Martin

>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
diff mbox

Patch

diff --git a/package/redis/redis.mk b/package/redis/redis.mk
index 51c1f9c..633d411 100644
--- a/package/redis/redis.mk
+++ b/package/redis/redis.mk
@@ -9,6 +9,10 @@  REDIS_SITE = http://download.redis.io/releases
 REDIS_LICENSE = BSD-3c (core); MIT and BSD family licenses (Bundled components)
 REDIS_LICENSE_FILES = COPYING
 
+define REDIS_USERS
+	redis -1 redis -1 * /var/lib/redis /bin/sh - Redis Server
+endef
+
 # Redis doesn't support DESTDIR (yet, see
 # https://github.com/antirez/redis/pull/609).  We set PREFIX
 # instead.
@@ -22,6 +26,7 @@  endef
 define REDIS_INSTALL_TARGET_CMDS
 	$(TARGET_MAKE_ENV) $(MAKE) $(REDIS_BUILDOPTS) -C $(@D) \
 		LDCONFIG=true install
+	$(INSTALL) -d -m 0700 $(TARGET_DIR)/var/lib/redis
 endef
 
 $(eval $(generic-package))