Project

General

Profile

Bug #1747

default PATH values doesn't include /usr/local prefix

Added by Egor Morozov over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
Start date:
07/31/2012
Due date:
% Done:

100%

For junior contributor:
No

Description

Hi,

We're running FusionInventory using cron, but as cron doesn't have any PATH variable by default, there's a line when running FusionInventory-Agent:
[debug] PATH is not set, using /sbin:/usr/sbin:/bin:/usr/bin as default
As FreeBSD is installing the software to /usr/local/bin & /usr/local/sbin by default, dmidecode doesn't work :-/

Probably there're two ways to fix the problem:
1) change the PATH variable to include same dirs in local
2) locate the binary before executing the command

History

#1 Updated by Guillaume Rousse over 5 years ago

  • Assignee set to Guillaume Rousse

That's neither FreeBSD nor dmidecode specific: if you have binaries outside of PATH, they won't be usable by the agent.

The actual question is how much should the software be able to auto-configure itself when its execution environement is unproperly configured. I'd rather make the error message in the logs more explicit and more visible to allow concerned people to adapt their own environnement, rather than extending hardcoded minimal and affecting every users.

#2 Updated by Egor Morozov over 5 years ago

Well, the problem is FreeBSD doesn't install any binaries to /usr/bin, whereas Linux does. There was a 'which' call somewhere in the code, why is it not used instead?

#3 Updated by Gonéri Le Bouder over 5 years ago

Just define the PATH in the crontab:

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

#4 Updated by Egor Morozov over 5 years ago

I know, but that's not really a good approach.

#5 Updated by Gonéri Le Bouder over 5 years ago

I disagree, there is no way to guess the correct PATH. For example, on a Solaris box, the PATH can be very complexe and will strongly depend on the sysadmin (e.g: GNU or Solaris tools).

Regarding your bug report, I agree /usr/local/bin and /usr/local/sbin should be add in this case.

#6 Updated by Guillaume Rousse over 5 years ago

I disagree extending those default hardcoded values just because it makes sense for some specific case. Sure, it doesn't realy hurt. But if tomorrow someone else uses the argument "my specific distribution uses /opt prefix by default, please add it to your minimal PATH value", what should we do ? This kind of issues should be handled either by final user, or by a environnement-specific distribution maintainer (for instance, the port maintainer), not at software level.

#7 Updated by Guillaume Rousse over 5 years ago

  • Subject changed from FreeBSD path is wrong to default PATH values doesn't include /usr/local prefix

#8 Updated by Egor Morozov over 5 years ago

Actually, this is default FreeBSD environment. The problem FreeBSD port is outdated, my patches were approved several months ago, but still not commited. As it takes lots of time, probably that's simpler to include this to mainstream (as Linux also may have software installed software to /usr/local/).

#9 Updated by Gonéri Le Bouder over 5 years ago

The /bin, /usr/bin, and /usr/local/bin directories are typically included in most users' $PATH setting (although this varies from implementation to implementation). http://en.wikipedia.org/wiki/PATH_(variable)

If we push /bin and /usr/bin, I can hardly understand we exclude /usr/local/bin.

#10 Updated by Guillaume Rousse over 5 years ago

Using different prefix is also sometimes a way to distinguish between different version of the same software: development version of yet unpackaged software in /usr/local, for instance. That's purely an hypothesis, as denoted by sometimes adverb. But as a software developer, I don't think that's our job to make this kind of hypothesis, whereas we're targetting end users (sysadmins) supposedly able to take this kind of decision...

Come on, this minimal value exists for years. If that was really such a problem, why would be notified only now ?

#11 Updated by Gonéri Le Bouder over 5 years ago

In this case, we should just die or print a warning if PATH is empty and let the sysadmin do his duty :).

Regarding the difference between / /usr and /usr/local, it's the reason why there is an order in the PATH definitions?

#12 Updated by Egor Morozov over 5 years ago

Well, is it possible to set the path in configuration file then? :)

#13 Updated by David Durieux over 5 years ago

All softwares installed by user in *BSD systems are installed in /usr/local/ to be separated with softwares installed by default when install the operating system.

If you use only /usr/, you say you use only Linux specification, so why not use only *BSD specification :p

That's why, is not found in /usr, try in /usr/local

#14 Updated by Gonéri Le Bouder over 5 years ago

David, if I follow this, we should add Solaris /usr/ccs/bin and /usr/sfw/bin too. I don't think the question is BSD related. It's just “What is a sensible default PATH definition generic enough to be used on every OS?”

#15 Updated by Veniamin Gvozdikov over 5 years ago

My be add configurability path for looking binaries?

#16 Updated by Gonéri Le Bouder over 5 years ago

That's what Egor Morozov suggested too. I would say think it's already the purpose of an environement VARIABLE.

#17 Updated by Guillaume Rousse over 5 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset commit:3582de3ab7be8a032e724c1da2d89efc3c84fd71.

#18 Updated by Guillaume Rousse over 5 years ago

  • Target version set to 2.2.5

As it seems I'll always lose in this documentation versus code debate, I just commited the desired change in 2.3.x and 2.2.x branches :)

#19 Updated by Gonéri Le Bouder over 5 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF