# ddclient not working via init script

## Rocky007

Hello,

i'm trying to use ddclient to update my ip to strato.

When starting via

```
ddclient -daemon=0 -debug -verbose -noquiet
```

it says success...

When starting via 

```
/etc/init.d/ddclient start
```

it gives me the following

```

SGC ~ # /etc/init.d/ddclient restart

 * Caching service dependencies ...                                                                                                                                                        [ ok ]

find: invalid mode '+0044'

 * Starting ddclient ...

WARNING:  file /etc/ddclient/ddclient.conf: Cannot open file '/etc/ddclient/ddclient.conf'. (Permission denied)

stat() on closed filehandle FD at /usr/sbin/ddclient line 986.

Use of uninitialized value $mode in bitwise and (&) at /usr/sbin/ddclient line 987.

readline() on closed filehandle FD at /usr/sbin/ddclient line 999.

WARNING:  file /etc/ddclient/ddclient.conf: Cannot open file '/etc/ddclient/ddclient.conf'. (Permission denied)

stat() on closed filehandle FD at /usr/sbin/ddclient line 986.

Use of uninitialized value $mode in bitwise and (&) at /usr/sbin/ddclient line 987.

readline() on closed filehandle FD at /usr/sbin/ddclient line 999.

WARNING:  file /var/cache/ddclient/ddclient.cache: Cannot open file '/var/cache/ddclient/ddclient.cache'. (Permission denied)

stat() on closed filehandle FD at /usr/sbin/ddclient line 986.

Use of uninitialized value $mode in bitwise and (&) at /usr/sbin/ddclient line 987.

readline() on closed filehandle FD at /usr/sbin/ddclient line 999.

 * start-stop-daemon: failed to start `/usr/sbin/ddclient'                                                                                                                                 [ !! ]

 * ERROR: ddclient failed to start

```

Whats going wrong here?

I need to set it up as a service starting on boot

----------

## xaviermiller

Hi!

Can you take a look at the init script which user is used?

That user need read rights to the configuration file, and write rights for the log and pid files

----------

## Rocky007

```
#!/sbin/openrc-run

# Copyright 1999-2011 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

if [ -d /run ] ; then

        PIDFILE=${PIDFILE:-/run/ddclient/ddclient.pid}

else

        PIDFILE=${PIDFILE:-/var/run/ddclient/ddclient.pid}

fi

depend() {

        before cron

        need net

        use dns logger squid

}

checkconfig() {

        local conf="/etc/ddclient/ddclient.conf"

        if [ -e "${conf}" ] ; then

                if [ -n "$(find /etc/ddclient -maxdepth 1 -name ddclient.conf -perm +0044)" ] ; then

                        eerror "${conf} must not be world or group readable. Try:"

                        eerror "    chmod 600 ${conf}"

                        eerror "    chown ddclient:ddclient ${conf}"

                        return 1

                fi

        else

                eerror "${conf} is needed to run ddclient"

                eerror "There is a sample file in /etc/ddclient/"

                return 1

        fi

}

start() {

        checkconfig || return 1

        local piddir=$(dirname ${PIDFILE})

        if [ ! -d ${piddir} ] ; then

                ebegin "Making ${piddir}"

                mkdir -p ${piddir}

                eend $?

                ebegin "Changing permissions of ${piddir}"

                chown ddclient:ddclient ${piddir}

                eend $?

        fi

        ebegin "Starting ${SVCNAME}"

        start-stop-daemon --start --user ddclient --exec /usr/sbin/ddclient \

                --name ddclient --pidfile ${PIDFILE} -- -pid=${PIDFILE}

        eend $?

}

stop() {

        ebegin "Stopping ${SVCNAME}"

        start-stop-daemon --stop --signal USR1 --pidfile ${PIDFILE}

        eend $?

}

```

I've chown the following to ddclient:ddclient

/etc/ddclient (folder)

/etc/ddclient/ddclient.conf (file)

/var/cache/ddclient (folder)

/var/cache/ddcleint/ddclient.cache (file)

now it gives me

```

SGC ddclient # /etc/init.d/ddclient restart

 * Stopping ddclient ...                                                                                                                                                                   [ ok ]

find: invalid mode '+0044'

 * Starting ddclient ...

Use of uninitialized value in string ne at /usr/sbin/ddclient line 2335.                                                                                                                   [ ok ]

SGC ddclient # /etc/init.d/ddclient status

 * status: crashed

```

----------

## ronaldoc

Hmm, how do we check if the user has read rights to the configuration file?

----------

## szatox

ls -l will print the owner and group of a file together with permissions as a set of flags (Read,Write,eXecute) for owner, followed by group and others.

Creating a new file requires write access to its parent directory.

----------

