# startup script won't start manually by non-privileged user (FreeBSD11)



## Plague (Oct 29, 2016)

for example, rc.d-script from net-p2p/transmission-daemon.
For some reasons, i don't need start it at boot.
In rc.conf set:
	
	



```
transmission_user="plague"
```
In freebsd 8.4
`$ /usr/local/etc/rc.d/transmission onestart`
works fine.
In 11 I got error:
	
	



```
limits: setrlimit datasize: Operation not permitted
```
It's because it tries to set limits (line 1075 in rc.subr 299349), that's not allowed for non-privileged users.

```
# Prepend default limits
_doit="limits -C $_login_class $_doit"
```
How I can disable this in that script?


----------



## acheron (Oct 29, 2016)

You're not supposed to launch startup script with a non root user.


----------



## Plague (Oct 29, 2016)

Thanks, Cap, but I asked for answer how I can resolve it. Or we are talk not about UNIX-system?


----------



## acheron (Oct 29, 2016)

Use sudo or switch to root user.


----------



## kpa (Oct 29, 2016)

That should work since running services on an unprivileged user is part of the rc(8) framework. I'd consider that a bug that needs fixing.


----------



## tobik@ (Oct 29, 2016)

Or run transmission-daemon(1) without the rc.d script.


----------



## acheron (Oct 29, 2016)

kpa said:


> That should work since running services on an unprivileged user is part of the rc(8) framework. I'd consider that a bug that needs fixing.


Where is it written ?


----------



## kpa (Oct 29, 2016)

acheron said:


> Where is it written ?



This is from /etc/rc.subr:


```
#       ${name}_user    n       User to run ${command} as, using su(1) if not
#                               using ${name}_chroot.
#                               Requires /usr to be mounted.
```


----------



## acheron (Oct 29, 2016)

That's not the same, you still need to run the script as root and then the startup script will use the ${name}_user to launch the binary.


----------



## kpa (Oct 29, 2016)

Aah yes, I missed that little detail. I assumed the error was occuring at system startup.


----------



## kpa (Oct 29, 2016)

Plague said:


> Thanks, Cap, but I asked for answer how I can resolve it. Or we are talk not about UNIX-system?



As noted by others you can't switch to another user on a UNIX or UNIX-like system unless you first acquire the superuser privileges. Acquiring the superuser privileges can be done with su(1) or security/sudo.


----------



## Plague (Oct 29, 2016)

> I'd consider that a bug that needs fixing.


i think the same.
If there is an option to run that service as an unprivileged user, there _must_ be the key to force not to set daemon limits and leave it on that user group level privileges.


----------



## acheron (Oct 29, 2016)

There is no bug to fix. Startup script are meant to run as root, period.


----------



## Plague (Oct 29, 2016)

khm... Directly for transmission, as user-level application, daemon level limits strongly *not* necessary, and furthermore, harmful.
imho.


----------



## Plague (Oct 31, 2016)

line 1075 in rc.subr 299349

```
# Prepend default limits
_doit="limits -C $_login_class $_doit"
```
changed to

```
if [ `whoami` != "root" ] && [ ${name} == transmission ]; then
  _doit="$_doit"
  else
  # Prepend default limits
  _doit="limits -C $_login_class $_doit"
fi
```


----------

