You are not logged in.
End result I want to achieve, find pam config files using pam_tally.so or pam_tally2.so in any package in the official repositories.
Is there already a tool that can do this I looked in devtools, pacutils, pacman-contrib and expac but could not find such a tool.
I can use pacman -Fy etc/pam.d/ to produce a list of packages owning a certain path.
From there is there a way to get the current package name how to get the archive name to check if it is in the package cache?
Then bsdtar extract the archive, grep output, clean and repeat.
Last edited by loqs (2020-07-28 22:05:23)
Offline
pacman -Sp $(pacman -Fq etc/pam.d/)
This will generate the list of remote urls to the packages in question. If you want to check against the local cache, the filename at the end of the url would/should match what'd be found in the cache - if not cached, curl the url, pipe to bsdtar with appropriate options, and then to grep.
EDIT: Holy awesome! The -Sp will actually print file:// urls for locally cached files, so you can skip that step.
Here's a start:
#!/bin/sh
pacman -Spdd $(pacman -Fq etc/pam.d/) | while read url; do
case $url in
file*)
bsdtar --include=etc/pam.d/* -xOf ${url#file://} | grep WHATAVER
;;
http*)
curl -s $url | bsdtar --include=etc/pam.d/* -xOf ${url#file://} | grep WHATAVER
;;
esac
done
EDIT: added 'dd' flags as per below.
Last edited by Trilby (2020-07-28 18:21:22)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Noticed some unexpected entries in the results:
pacman -Sp community/xpra
https://mirrors.kernel.org/archlinux/community/os/x86_64/python-lz4-2.2.1-4-x86_64.pkg.tar.zst
https://mirrors.kernel.org/archlinux/extra/os/x86_64/xf86-video-dummy-0.3.8-4-x86_64.pkg.tar.zst
https://mirrors.kernel.org/archlinux/community/os/x86_64/python-netifaces-0.10.9-3-x86_64.pkg.tar.xz
file:///var/cache/pacman/pkg/python-rencode-1.0.6-3-x86_64.pkg.tar.xz
https://mirrors.kernel.org/archlinux/extra/os/x86_64/freeglut-3.2.1-2-x86_64.pkg.tar.zst
https://mirrors.kernel.org/archlinux/extra/os/x86_64/python-opengl-3.1.5-1-any.pkg.tar.zst
https://mirrors.kernel.org/archlinux/community/os/x86_64/xpra-3.0.9-3-x86_64.pkg.tar.zst
Offline
Ha ha, oops! This is better:
pacman -Spdd community/xpra
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Thank you Trilby.
Added -L to curl invocation for redirections and for http replaced ${url#file://} with - in the bsdtar invocation to use stdin.
Offline
Any url handled by pacman must be usable via libcurl:
#!/bin/sh
pacman -Spdd $(pacman -Fq etc/pam.d/) | while read url; do
curl -s $url | bsdtar --include=etc/pam.d/* -xOf - | grep WHATAVER
done
The http block anyway needed to use "-". But curl can read a file:// url from disk and emit its contents on stdout, and essentially serves as an exotic syntax for `cat`.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Nice. I suspected curl could handle "file://" but I tried it once and it didn't work as intended. I didn't investigate further at the time.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
curl does require full paths, but that's how file:// urls are defined. It's also possible to compile curl with file:// support disabled. I'd be interested to hear what happened when you "tried it once and it didn't work as intended".
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Not much to hear: I fucked something up apparently! I can't replicate it. At the time it was nested in the script and simply didn't produce any expected output. I suspect the other glaring error in the very rough draft script was the cause: I copy-pasted the line from the local file case statement to the curl one but didn't replace the ${url...} with a "-" or /dev/stdin in the bsdtar command. So curl likely worked but the pipeline ignored it's output. But this is just speculation as it was an isolated incident while I was tinkering for all of 5 minutes to find a rough first pass at an idea of how to accomplish this.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline