Problem Installing from tar file.

I am running 64 bit openSUSE13.1 with KDE desktop and trying to install Netdiscover. I have downloaded the tar file, extracted it and made sure all the libraries are in place. When I run ./configure all seems to be OK. Similarly when I run make I do not see any errors. If then run make install I get the following:-

~/Downloads/Netdiscover/netdiscover-0.3-beta6> make install
Making install in src
make[1]: Entering directory `/home/alastair/Downloads/Netdiscover/netdiscover-0.3-beta6/src'
make[2]: Entering directory `/home/alastair/Downloads/Netdiscover/netdiscover-0.3-beta6/src'
/bin/sh ../mkinstalldirs /usr/local/sbin
  /bin/sh ../libtool --mode=install /usr/bin/install -c netdiscover /usr/local/sbin/netdiscover
/usr/bin/install -c netdiscover /usr/local/sbin/netdiscover
/usr/bin/install: cannot create regular file '/usr/local/sbin/netdiscover': Permission denied
make[2]: *** [install-sbinPROGRAMS] Error 1
make[2]: Leaving directory `/home/alastair/Downloads/Netdiscover/netdiscover-0.3-beta6/src'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory `/home/alastair/Downloads/Netdiscover/netdiscover-0.3-beta6/src'
make: *** [install-recursive] Error 1
alastair@IBMx3400:~/Downloads/Netdiscover/netdiscover-0.3-beta6> 

Ah, I thought. I see there is a permission issue with /usr/local/sbin so I ran ‘su -’ and then tried ‘make install’ again. This time all seemed to go according to plan but when I then tried to run sudo netdiscover from my console I received an error message that netdiscover could not be found. The binary ‘netdiscover’ was however there in /usr/local/sbin/. I tried using “sudo make install” instead of su - and still no joy.
What is going on and what am I doing wrong?

Budgie2

sudo has the PATH-Variable of the User:
Try

echo $PATH

and you will see, there is no /usr/local/sbin/ in it.

So start your Programm with the whole Path.

/usr/local/sbin/ is not in the path.
So either specify the full path (“sudo /usr/local/sbin/netdiscover”), add /usr/local/sbin to the path, or create a symlink/copy netdiscover to some directory in the path like /usr/sbin/.

Or, install the program to /usr instead of /usr/local in the first place. How you would do that depends on the particular build system though, probably by adding the --prefix parameter to ./configure. Try to run ./configure --help to find out whether that’s supported.

/usr/local/sbin is not in root’s path either, only /sbin and /usr/sbin.

But I forgot something in my previous post:
/usr/sbin will not be in the path of a normal user, so just installing netdiscover there probably won’t help for sudo anyway.

On 2014-10-11 14:26, Budgie2 wrote:

> What is going on and what did I do wrong?

Trying to run a program as user that is intended to be used as root.

Same for installation: you need to be root to install any program into
the system areas.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Hi Robin, and thanks for the reply but …

[QUOTE=robin_listas;2668902]On 2014-10-11 14:26, Budgie2 wrote:

> What is going on and what did I do wrong?

Trying to run a program as user that is intended to be used as root.

I was running it using sudo but still not working.

Same for installation: you need to be root to install any program into
the system areas.

I installed as root also.

The problem is as noted by others above. /usr/local/sbin is not in path.

Regards,
Budgie2

Hi wolfi323 and many thanks. I had failed to appreciate that sudo used the path of the local user so that is why it would not run.
On the other hand /usr/local/sbin is in my root’s path for some reason so if I run as su - it works however…

What the the “correct” way to sort this out? Thanks to you I now know there are several options but what I am not sure of is the conventional solution for binaries installed this way. There is an option in the installer as follows:-

By default, make install' will install the package's files in /usr/local/bin’, /usr/local/man', etc. You can specify an installation prefix other than /usr/local’ by giving configure' the option –prefix=PATH’.

No mention of /usr/local/sbin and when I look in /usr/local/bin there is no sign of netdiscover. I am nervous about specifying a new PATH using --prefix=PATH when the installation does not put the program where stated.

When you have time I would appreciate further advice but meanwhile you have solved my immediate problem. Many thanks again.

Budgie2

You will be root with the PATH, aliases, etc. that normal;y go with a root login, by using

su -

And please next time show what you do complete, that is prompt, command, output (the only bit you posted above) and the next prompt. Then we can see and not guess what you do

Yes, sorry.
It is in root’s path indeed.

I accidentally ran “su” instead of “su -” to switch to root, when I checked… :shame:
Strange though that /sbin and /usr/bin were there, but well.

No mention of /usr/local/sbin and when I look in /usr/local/bin there is no sign of netdiscover.

Well, as netdiscover is intended to be used by root only, it is installed to $prefix/sbin instead of $prefix/bin.
The help page just doesn’t mention every single directory things might get installed to, but all of them will be subdirectories of the specified prefix (unless overridden by other options).
So add --prefix=/usr and netdiscover, the executable, will be put into /usr/sbin.
Btw, this is done automatically when you build a package on OBS, so it definitely works. Otherwise your /usr/sbin would be completely empty… :wink:

But if the executable is the only file needed anyway, it might be easier to just copy/move it to /usr/sbin instead of recompiling it.
I had a look at the one existing package on OBS, and this indeed seems to be the case. Then there’s the man page as well, which you could also just copy/move manually to /usr/share/man/man8. Or leave it in /usr/local/share, it should be found there as well.

Hi Wolfi,
Since I shall seldom be using this and don’t want others playing/snooping around will leave as is for now. BTW what is OBS?
Thanks again for the help.
Budgie2

“Open Build Service”, or “openSUSE’s Build Service” where all packages for the distribution (and many others) are built.
https://build.opensuse.org/

The software search at http://software.opensuse.org/search in fact searches through the packages on OBS.

On 2014-10-11 16:46, Budgie2 wrote:
>
> Hi Robin, and thanks for the reply but …
>
> robin_listas;2668902 Wrote:
>> On 2014-10-11 14:26, Budgie2 wrote:
>>
>>> What is going on and what did I do wrong?
>>
>> Trying to run a program as user that is intended to be used as root.
>>
> I was running it using sudo but still not working.

Yes, but a known feature of sudo is that it doesn’t apply root’s path in
advance, so that if the program you tell it to run is in
/usr/local/sbin/, it will not find it. You have to specify the full path.

You see, “using sudo” is not the same as “being root”. If you /were/
root, via “su -”, not “su”, then your command would have run immediately.

>> Same for installation: you need to be root to install any program into
>> the system areas.
>>
> I installed as root also.

No, you first tried to install as plain user, and seeing the permission
error, you used sudo :slight_smile:

>> The problem is as noted by others above. /usr/local/sbin is not in
>> path.

Not in the user path. It is in root’s path :wink:

There is a difference.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On 2014-10-11 17:26, wolfi323 wrote:

> The help page just doesn’t mention every single directory things might
> get installed to, but all of them will be subdirectories of the
> specified prefix.
> So add --prefix=/usr and netdiscover, the executable, will be put into
> /usr/sbin.
> Btw, this is done automatically when you build a package on OBS, so it
> definitely works. Otherwise your /usr/sbin would be completely empty…
> :wink:
>
> But if the executable is the only file needed anyway, it might be easier
> to just copy/move it to /usr/sbin instead of recompiling it.

Eumm… The correct place for packages you build locally is to install
them all under /usr/local/something. That something can be lib, bin,
etc, man, share, var… the whole thing can be there, as needed.

The idea is that you can either wipe it all and remove the things you
built, different than those from the distributions, or on the contrary,
wipe all the distribution packages and reinstall or update.

Which is why some of us put /usr/local/ in its own partition, too :wink:

Thus, better leave netdiscover in there.

> I had a look at the one existing package on OBS, and this indeed seems
> to be the case. Then there’s the man page as well, which you could also
> just copy/move manually to /usr/share/man/man8. Or leave it in
> /usr/local/share, it should be found there as well.

No, the OBS is different: it is “the distribution package”. And it is
also a package, an rpm, which makes it easy to remove/replace/update.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Hi Robin,
Many thanks. I will do as you suggest in future. Meanwhile did you find an rpm package for netdiscover? Darned if I could which is why I built from tar file.
Bottom line is that having sorted out how to run it, it works a treat. I needed it to pin down a rogue managed switch that will not accept a fixed IP but for which I know the MAC address.
Thanks again all.
Budgie2

On 2014-10-11 19:26, Budgie2 wrote:
>
> Hi Robin,
> Many thanks. I will do as you suggest in future. Meanwhile did you
> find an rpm package for netdiscover? Darned if I could which is why I
> built from tar file.

There is for factory and 12.3, not 13.1

http://software.opensuse.org/package/netdiscover?search_term=netdiscover

> Bottom line is that having sorted out how to run it, it works a treat.
> I needed it to pin down a rogue managed switch that will not accept a
> fixed IP but for which I know the MAC address.

The tool is unfamiliar to me. I may have a look some day.

I once saw a neat Windows tool. It scanned or listened on a network, and
listed everything in sight. Not only the IPs, but the operating systems
they used, and their patch state: ie, machine so and so is vulnerable
because it is running that version of such service.

Very useful. Not for attacking, mind, but to find out those machines and
mend them :wink:

(Yes, it also listed Linux machines :slight_smile: )


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

True for 13.1 and at least some releases before, but this has been changed in Factory a while ago, so in 13.2 sudo will find executables in /sbin and /usr/sbin. (I’m not sure about /usr/local/sbin now though)

On 2014-10-11 23:46, wolfi323 wrote:
>
> robin_listas;2668945 Wrote:
>> Yes, but a known feature of sudo is that it doesn’t apply root’s path in
>> advance, so that if the program you tell it to run is in
>> /usr/local/sbin/, it will not find it. You have to specify the full
>> path.
> True for 13.1 and at least some releases before, but this has been
> changed in Factory a while ago, so in 13.2 sudo will find executables in
> /sbin and /usr/sbin.

Interesting…


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Well, actually it’s “just” a change in the default /etc/sudoers file.
So if you modified that, you shouldn’t see a difference.

Here’s the commit:
https://build.opensuse.org/package/rdiff/openSUSE:Factory/sudo?linkrev=base&rev=61

I.e. they added those lines to the default /etc/sudoers:

## Path that will be used for every command run from sudo 
Defaults secure_path="/usr/sbin:/usr/bin:/sbin:/bin"

PS, @Budgie2:
If you add those lines manually, sudo should find applications in /sbin and /usr/sbin also on 13.1.
You could of course also add /usr/local/sbin this way.

On 2014-10-12 13:36, wolfi323 wrote:
>
> robin_listas;2669004 Wrote:
>> Interesting…
> Well, actually it’s “just” a change in the default /etc/sudoers file.
> So if you modified that, you shouldn’t see a difference.

You get an /etc/sudoers.rpmnew file for your consideration :wink:

>
> Here’s the commit:
> http://tinyurl.com/mmenqvg
>
> I.e. they added those lines to the default /etc/sudoers:
>
> Code:
> --------------------
> ## Path that will be used for every command run from sudo
> Defaults secure_path="/usr/sbin:/usr/bin:/sbin:/bin"
>
> --------------------

It makes sense, yes, had be done there.

Still, it is interesting they made this change :slight_smile:

> You could of course also add /usr/local/sbin this way.

Purists and security paranoids would cringe :wink:


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Yeah, right.
But your modified file will not be changed automatically, so sudo won’t change its behaviour after you upgrade to 13.2 if you modified it.
That’s what I wanted to stress.

It makes sense, yes, had be done there.

Still, it is interesting they made this change :slight_smile:

Well, apparently they also contemplated a patch to sudo to always add /sbin and /usr/sbin to the path, similar to one that was added to su years ago (and is now upstream).
See this bug report:
http://bugzilla.opensuse.org/show_bug.cgi?id=864115

> You could of course also add /usr/local/sbin this way.

Purists and security paranoids would cringe :wink:

Maybe.

But personally I don’t really see a problem with that.
Only root can put stuff into /usr/local/sbin with the standard directory permissions, and only root can change those permissions either.
And if somebody gains root privileges to put something into /usr/local/sbin, he can just as well put it into /sbin or /usr/sbin, I’d say… :wink: