LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Unwelcome triggering of hp-upgrade on 64-current. (https://www.linuxquestions.org/questions/slackware-14/unwelcome-triggering-of-hp-upgrade-on-64-current-4175451943/)

GazL 02-27-2013 12:54 PM

Unwelcome triggering of hp-upgrade on 64-current.
 
Found this in my /var/log/syslog
Code:

ws1 hp-upgrade: hp-upgrade[1668]: warning:  distro is not found in AUTH_TYPES
Now I don't have a printer attached to this box, but I can remember that I accidentally caught the print hot-key in an app at around the timestamp of this message in my syslog which likely triggered this message.

I *really* don't like some arbitrary bit of python code trying to update bits of my system automatically from an external site, and I especially dislike it when it is an unrequested action and outside of package-management.

I don't know whether others will also perceive this as unwelcome or a problem, but I thought it worth raising.

fskmh 02-27-2013 04:47 PM

What I find interesting about the script in question (base/password.py) is that although Slackware is listed in AUTH_TYPES:

Code:

AUTH_TYPES ={'mepis':'su',
            'debian':'su',
            'suse':'su',
            'mandriva':'su',
            'fedora':'su',
            'redhat':'su',
            'rhel':'su',
            'slackware':'su',
            'gentoo':'su',
            'redflag':'su',
            'ubuntu':'sudo',
            'xandros':'su',
            'freebsd':'su',
            'linspire':'su',
            'ark':'su',
            'pclinuxos':'su',
            'centos':'su',
            'igos':'su',
            'linuxmint':'sudo',
            'linpus':'sudo',
            'gos':'sudo',
            'boss':'su',
            'lfs':'su',
            }

The function that attempts to identify the name of the distro so that it can initiate the upgrade doesn't know what file to look for on Slackware:

Code:

def get_distro_name():
    os_name = None;
    if utils.which('lsb_release'):
      name = os.popen('lsb_release -i | cut -f 2')
      os_name = name.read().strip()
      name.close()
    else:
      name = os.popen("cat /etc/issue | awk '{print $1}' | head -n 1")
      os_name = name.read().strip()
      name.close()

    if "redhatenterprise" in os_name.lower():
        os_name = 'rhel'
    elif "suse" in os_name.lower():
        os_name = 'suse'

    return os_name

I'm not sure why they fall back to /etc/issue because that is almost always going to have escape sequences in it instead of static strings that can be awked. Seems trivially easy to fix but then instead of getting the warning message we'll get a prompt for the root password whenever upgrade.py gets called.

volkerdi 02-27-2013 05:42 PM

Quote:

Originally Posted by fskmh (Post 4901161)
Seems trivially easy to fix but then instead of getting the warning message we'll get a prompt for the root password whenever upgrade.py gets called.

And who knows what the upgrade will do, entirely outside of the packaging system? Seems better to leave it broken. I looked to see if there was a ./configure option to disable this behavior, but it appears that there is not.

cwizardone 02-27-2013 06:01 PM

Not sure if this has anything at all to do with it, but since the "upgrade" I've noticed it, hplips, automatically turns on my printer whether I want it to or not.

GazL 02-27-2013 06:40 PM

Quote:

Originally Posted by volkerdi (Post 4901194)
And who knows what the upgrade will do, entirely outside of the packaging system? Seems better to leave it broken. I looked to see if there was a ./configure option to disable this behavior, but it appears that there is not.

Just did exactly the same Pat. A quick grep seems to show that that hp-upgrade gets called from all over the hplip python sources in /usr/share/hplip. Rather than leave it broken, I wonder if we could replace hp-upgrade with some sort of no-op (just a sys.exit(0) or however it's done in python - not one of my languages). Actually, why not just replace it with a symlink to /usr/bin/true.

fskmh 02-28-2013 03:26 AM

On further inspection it seems that hplip is not capable of auto-installing on Slackware because get_distro() in installer/core_install.py doesn't have the necessary functionality to identify Slackware due to its reliance on lsb_release:

Code:

def get_distro(self):
        log.debug("Determining distro...")
        self.distro, self.distro_version = DISTRO_UNKNOWN, '0.0'

        found = False

        lsb_release = utils.which("lsb_release")

        if lsb_release:
            log.debug("Using 'lsb_release -is/-rs'")
            cmd = os.path.join(lsb_release, "lsb_release")
            status, name = utils.run(cmd + ' -is', self.passwordObj)
            name = name.lower().strip()
            log.debug("Distro name=%s" % name)
            if name.find("redhatenterprise") > -1:
                name="rhel"
.
.
.

and then the familiar fall-back to /etc/issue:

Code:

if not found:
            try:
                name = file('/etc/issue', 'r').read().lower().strip()
            except IOError:
                # Some O/Ss don't have /etc/issue (Mac)
                self.distro, self.distro_version = DISTRO_UNKNOWN, '0.0'
            else:
                if name.find("redhatenterprise") > -1:
                    name="rhel"
.
.
.

The bottom line is that is_auto_installer_support() must return false:
Code:

def is_auto_installer_support(self, distro_version = DISTRO_VER_UNKNOWN):
        if not self.distro_name:
            self.get_distro()
            self.distro_name = self.distros_index[self.distro]

        if distro_version == DISTRO_VER_UNKNOWN:
            distro_version = self.distro_version

        if self.distro != DISTRO_UNKNOWN and distro_version != DISTRO_VER_UNKNOWN and self.get_ver_data('supported
', False,distro_version):
            log.debug("Auto installation is supported for Distro =%s version =%s "%(self.distro_name, distro_versi
on))
            return True
        else:
            log.debug("Auto installation is not supported for Distro =%s version =%s "%(self.distro_name, distro_v
ersion))
            return False

So the question is, what value can Slackware users derive from having hplip accessory programs other than hp-update being able to identify the distro name? If anyone can think of some benefit, here's my patch:

Code:

--- hplip-3.13.2/base/password.py.orig  2013-02-28 09:30:57.442134662 +0200
+++ hplip-3.13.2/base/password.py      2013-02-28 10:48:43.636353992 +0200
@@ -67,6 +67,14 @@
        name = os.popen("cat /etc/issue | awk '{print $1}' | head -n 1")
        os_name = name.read().strip()
        name.close()
+    try:
+      with open('/etc/os-release') as f: pass
+      name = os.popen("grep -w ID /etc/os-release | awk -F= '{print $2}'")
+      os_name = name.read().strip()
+      log.info(("Distro was identified as %s\n") %os_name)
+      name.close()
+    except IOError as e:
+      log.error("Could not access file named /etc/os-release\n")
 
    if "redhatenterprise" in os_name.lower():
        os_name = 'rhel'

P.S. You don't have to rebuild the hplip package, you can just edit /usr/share/hplip/base/passwd.py with the relevant changes if you like.

GazL 02-28-2013 04:36 AM

Thanks for that. Yes, your patch fixes the OS detection, but hplip still makes a couple of unwanted outbound connections to hp.com and sourceforge.

Here's my patch ;)

Code:

--- upgrade.py.orig    2013-02-28 10:23:19.062450195 +0000
+++ upgrade.py  2013-02-28 10:27:38.242010423 +0000
@@ -214,9 +214,8 @@
 try:
    change_spinner_state(False)
    core =  CoreInstall(MODE_CHECK)
-    if not utils.check_network_connection():
-        log.error("Either Internet is not working or Wget is not installed.")
-        clean_exit(0)
+    log.info("Upgrades?  We don't want no stinkin' upgrades!")
+    clean_exit(0)
 
    installed_version=sys_conf.get("hplip","version","0.0.0")
    log.debug("HPLIP previous installed version =%s." %installed_version)


Nh3xus 07-17-2013 02:55 PM

Bumping this thread for a fix. :hattip:

There's an even easier fix to this :

You just have to modify this line in the passwd.py :

'slackware':'su',

and change it to this :

'slackware':'su -',

This did the trick on my -current 32 bits Slackware box.

Hope it helps :)

volkerdi 07-17-2013 04:01 PM

What kind of fix are you looking for? A similar patch to the one above was already applied to -current to disable hp-upgrade on Slackware. Actually making the feature work seems like a bad idea to me.

Nh3xus 07-17-2013 04:33 PM

Hi Pat,

I was just trying to get my HP Printer to work with my Slackware -Current 32 bits install and a search engine gave me this thread.

My model is supported by hplip.

I was having the same warning as the author about the distro detection not being correctly detected.

The printer was recognized but I had an error saying 'Communication error with the device' making the scanner function not available in Xsane.

After applying my fix, I ran hp-setup again to install my printer the right way.

My post should be concidered as a FYI, nothing more :)

chrisretusn 07-17-2013 07:00 PM

Making it work definitely seems like a bad idea to me.


All times are GMT -5. The time now is 07:11 PM.