I had version 7.32.2-1 agent of an app installed on an Ubuntu server. I then uninstalled it and installed an older version (7.31.1-1). dpkg shows that v7.31.1-1 is installed:
# dpkg -l | grep -i -agent
ii -agent 1:7.31.1-1 amd64
However, when I look up the package from debianpackage bigfix inspector still shows the v7.32.2-1:
# /opt/BESClient/bin/qna
Q: packages "-agent" of debianpackages
A: -agent: 1:7.32.2-1
T: 37143
I’ve restarted the BES Client (10.0.4.32) and even restarted the Ubuntu serve instance. Is there a reason why qna isn’t reflecting the version that dpkg -L shows?
dpkg, and our inspectors, do have some weird behavior because debianpkgs can be known even if they’re not ‘installed’. There is a whose() filter for that, let me see if I can find it.
It’s described a bit at https://developer.bigfix.com/relevance/reference/debian-base-package.html
I don’t have an ubuntu handy at the moment, but try these in the qna under the client directory:
Q: (packages “-agent”) whose (currently installed of it) of debianpackages
Q: installed versions of packages “-agent” of debianpackages
So apparantly it is not installed according to the debianpackages/ debianpackagescache (but it is according to dpkg -L ) ?
Q: package "-agent" whose (currently installed of it) of debianpackages
E: Singular expression refers to nonexistent object.
T: 13252
I have never been able to get ‘installed versions’ working for debianpackages. the package does at times contains the version so I’ve parsed that in a different query so that’s not a big concern.
# /opt/BESClient/bin/qna
Q: installed versions of packages of debianpackages
E: The operator "installed versions" is not defined.
had to use base package to get the installed version.
q: base package “-agent” of debianpackages
However. Even though the result is a Version, it isn’t acting like it when I try < or > . dpkg -l and this inspector prefixes “1:” onto some debianpackage installed versions. Not sure if that is causing it to not be treated like a version or not.
Q: installed version of base package "-agent" of debianpackages
A: 1:7.31.1-1
T: 8852
Q: exists base package "-agent" whose (exists installed version whose (it < "7.32.3-1") of it) of debianpackages
E: The operator "less than" is not defined.
@cstoneba
Object types will matter here.
https://developer.bigfix.com/relevance/reference/debianpkg-version.html
the installed version and pkg version both return a debianpkg version
which is different than a version
Q: (name of it |"noname",installed version of it as string|"noVer") of base packages whose (name of it contains "agent") of debianpackages
A: gnupg-agent, noVer
A: zabbix-agent, 1:4.0.17+dfsg-1
A: besagent, 10.0.3.66
A: libpolkit-agent-1-0, 0.105-26ubuntu1.1
A: mail-transport-agent, noVer
A: mailagent, noVer
A: lxd-agent-loader, 0.4
A: gpg-agent, 2.2.19-3ubuntu2.1
T: 68366
Maybe something more like this?
Q: (name of it, installed version of it, installed version of it as string as version) of base packages "zabbix-agent" whose (installed version of it as string as version < "1:4.0.18+dfsg-1") of debianpackages
A: zabbix-agent, 1:4.0.17+dfsg-1, 1:4.0.17+dfsg-1
T: 46973
so your revised would be:
Q: exists base package "-agent" whose (exists installed version whose (it as string as version < "7.32.3-1") of it) of debianpackages
Interesting side note: Casting to Version object seems to work a bit differently between Windows and Linux.
Windows strips down to the dotted portions whereas Linux allows for : and - portions to remain.
Yes, this gets me in the right direction:
exists base package "-agent" whose (exists installed version whose (it as string as version < "7.32.3-1") of it) of debianpackages
Does that seam like a bug in the Linux inspector then? Would think things should act the same across platforms when possible.
Edit:
This returns TRUE:
Q: exists base package "-agent" whose (exists installed version whose (it as string as version < "7.32.3-1") of it) of debianpackages
A: True
T: 8104
But this also returns TRUE, but should be FALSE because the installed version is 7.31.1-1
Q: exists base package "-agent" whose (exists installed version whose (it as string as version < "7.0.3-1") of it) of debianpackages
A: True
T: 8119
Q: (installed version of it as string as version) of base package "-agent" of debianpackages
A: 1:7.31.1-1
T: 8176
example on linux showing that the “1:” at the start of the version is throwing it off:
Q: "1:7.31.1-1" as string as version > "6"
A: False
T: 62
Q: "7.31.1-1" as string as version > "6"
A: True
T: 64
This seem to be a working solution for me:
Q: exists base package "-agent" whose (exists installed version whose ((it < "7.32.3-1") of (following text of first ":" of (it as string)as version)) of it) of debianpackages
A: True
T: 8085
Q: exists base package "-agent" whose (exists installed version whose ((it < "7.30.3-1") of (following text of first ":" of (it as string)as version)) of it) of debianpackages
A: False
T: 8300
1 Like
For Linux, the castinto to version seems to “do the right thing” with the leading 1: Could you just:
Q: exists base package "-agent" whose (exists installed version whose (it as string as version < "1:7.32.3-1") of it) of debianpackages
yes, that does work. thanks