Re: differences between service command and running command directly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


I always have read that running services using service command is safer than
using the script directly

the key is that service runs the script with env -i (with an empty
enviroment) so if there is any wrong variable you are protected.

My problem is that in /etc/profile.d/ I have defined a wrong variable and
when I run /etc/init.d/httpd status the scripts runs with the corrupt

with service you allways run with an empty enviroment so I don´t get the

Thank you all for your help. I hope it gives a bit of light about it ;-)


2011/10/4 Daniel Carrillo <daniel.carrillo@xxxxxxxxx>

> 2011/10/4 Barry Brimer <lists@xxxxxxxxxx>:
> >> I use service and running the command in /etc/init.d/ directly  to run
> the
> >> services in that directory. Until now I thought it was the same to run,
> >> for
> >> example:
> >>
> >> service httpd status
> >>
> >> and
> >>
> >> /etc/init.d/httpd status
> >>
> >> but now I have a server that they don´t do the same:
> >
> > <snip>
> >
> >> Anyone can explain me this? I suposse it´s something about enviroment
> >> variables, but I can´t see the difference
> >
> > I would run both with bash -x and redirect the output and compare or diff
> > them.
> >
> > bash -x service httpd status >/tmp/service.log 2>&1
> >
> > bash -x /etc/init.d/httpd status >/tmp/initscript.log 2>&1
> IMHO: This has no sense, because service is only a wrapper who calls
> to /etc/init.d/xservice
> man service
> service runs a System V init script in as predictable environment as
> possible, removing most environment variables and with current working
> directory set to /.
> Best regrads.
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe

[CentOS]     [Kernel Development]     [Red Hat Install]     [PAM]     [Fedora Users]     [Red Hat Development]     [Red Hat 9]     [Big List of Linux Books]     [Linux Admin]     [Photo Sharing]     [Hot Springs]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]

Add to Google Powered by Linux