su: command not found

Issues related to applications and software problems and general support
Post Reply
Serix
Posts: 4
Joined: 2020/03/26 13:03:41

su: command not found

Post by Serix » 2020/03/26 13:18:54

Dear CentOS Community.

Can someone explain what changed in CentOS 8 regarding bash scripting?

We have some scripts that are installing a RPM package, put this in Startup scripts and starting a service. All was working fine till Centos 7 latest version. Now we get below error and we don't know how to deal with it (sorry a bit newbie here :|)

● *****.service - SYSV: *********
Loaded: loaded (/etc/rc.d/init.d/******; generated)
Active: active (exited) since Thu 2020-03-26 14:20:45 CET; 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 17655 ExecStop=/etc/rc.d/init.d/****** stop (code=exited, status=127)
Process: 17713 ExecStart=/etc/rc.d/init.d/******* start (code=exited, status=0/SUCCESS)

Mar 26 14:20:43 ******3 systemd[1]: Starting SYSV: ****************...
Mar 26 14:20:43 *******3 ********[17713]: Starting *******: /etc/rc.d/init.d/**********: line 28: su: command not found
Mar 26 14:20:45 *******3 systemd[1]: Started SYSV: ******************.

Could someone help us on that?

nouvo09
Posts: 182
Joined: 2009/09/19 19:21:36
Location: Paris, France

Re: su: command not found

Post by nouvo09 » 2020/03/27 16:11:18

su in an sysV script? What for ? it is anyway run as root.
Member of centos-FR forum

Serix
Posts: 4
Joined: 2020/03/26 13:03:41

Re: su: command not found

Post by Serix » 2020/03/27 16:15:08

Sorry, I've owned all this from my predecessor...

Could you suggest something?

pjsr2
Posts: 448
Joined: 2014/03/27 20:11:07

Re: su: command not found

Post by pjsr2 » 2020/03/27 16:51:18

Check in the init script if this su command uses the absolute path name, if not add the full path name.
Systemd uses a very restricted set of environment variables when executing the scripts.

If that does not help:

Rewrite the SysV init script as a systemd .service file.
In the systemd service you can use "User=username" to run the program as the specified user.

Serix
Posts: 4
Joined: 2020/03/26 13:03:41

Re: su: command not found

Post by Serix » 2020/03/30 09:19:40

Could you please let me know what changed regarding security on CentOS 8? All was working fine till Centos 7 latest release... :|

User avatar
TrevorH
Forum Moderator
Posts: 28033
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: su: command not found

Post by TrevorH » 2020/03/30 09:23:40

It's not possible to tell what has changed, It's been 5 years between 7 and 8 and many things will have changed, some documented in the RHEL Release Notes upstream, others will have changed without notice. The best advice here is to turn your current initscript into a systemd unit file as they're really easy to write and will allow you to avoid the use of su at all.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

Serix
Posts: 4
Joined: 2020/03/26 13:03:41

Re: su: command not found

Post by Serix » 2020/03/30 09:37:04

Ok, thank you very much. Will give it a try to rewrite that scripts or to adapt as you have suggested.

Post Reply

Return to “CentOS 8 - General Support”