0

I have added a script to /usr/local/bin/apt-get on an Ubuntu Trusty system which does some checking that is required before launching the "official" apt-get.

For reasons I simply cannot comprehend this script is completely ignored despite everything telling me that it shouldn't be.

For testing purposes the script currently does nothing and should simply exit, but it is never launched anyway.

/usr/local/bin has priority in the $PATH:

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ which apt-get
/usr/local/bin/apt-get
$ ls -l /usr/local/bin/apt-get
-rwxr-xr-x 1 root root 553 Apr 16 03:01 /usr/local/bin/apt-get

strace appears to execute the script:

$ strace apt-get
execve("/usr/local/bin/apt-get", ["apt-get"], [/* 26 vars */]) = 0
[...]
open("/usr/local/bin/apt-get", O_RDONLY) = 3
[...]
read(10, "#!/bin/sh\n\n# Note: this little s"..., 8192) = 553

Yet the script is clearly being ignored:

$ apt-get
apt 1.0.1ubuntu2 for amd64 compiled on Oct 28 2014 20:55:14
Usage: apt-get [options] command
...

Launching /usr/local/bin/apt-get directly exits silently, as it should, so the script itself is executable and works correctly.

Could this be a hidden security setting that I know nothing about?

5
  • Okay.... this started working in one SSH session, then eventually started working in another. Could this be a cache/memory issue?
    – Ken Sharp
    Apr 16, 2015 at 2:27
  • Regarding your recent comment--are you still able to produce the problem? If so, what's the output of type -a apt-get? Apr 16, 2015 at 4:12
  • @EliahKagan It's still working. I could test further with a different script just to see what happens. Might lead to a bug report. I'll update if/when I know what's going on.
    – Ken Sharp
    Apr 17, 2015 at 1:40
  • This definitely still occurs on occasion, usually after changing the script multiple times (and saving each time). There's a nasty little bug hanging around here somewhere but I can't find it. Reboot solves the problem which suggests there's a cache issue somewhere. sync doesn't clear the issue. I need to look into this further.
    – Ken Sharp
    Dec 18, 2015 at 15:45
  • man bash gives “Bash uses a hash table to remember the full pathnames of executable files (see hash under SHELL BUILTIN COMMANDS below). A full search of the directories in PATH is performed only if the command is not found in the hash table.” I think that this may be the answer. I'll update when I'm sure. I opened this so long ago that I may have had "old" bash terminals open using hashed values and simply cannot remember.
    – Ken Sharp
    Mar 3, 2019 at 17:44

0

You must log in to answer this question.

Browse other questions tagged .