Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From e7f5fcd53b1d997152a99b1418691e899557c346 Mon Sep 17 00:00:00 2001
- From: maromnztt <[email protected]>
- Date: Mon, 4 Aug 2025 01:26:06 -0300
- Subject: [PATCH] Patch run as root and add desktop files
- ---
- .gitignore | 2 ++
- PKGBUILD | 20 +++++++++++++++++++-
- org.gnome.pkexec.zenmap.policy | 19 +++++++++++++++++++
- sudo_with_pkexec.patch | 18 ++++++++++++++++++
- 4 files changed, 58 insertions(+), 1 deletion(-)
- create mode 100644 org.gnome.pkexec.zenmap.policy
- create mode 100644 sudo_with_pkexec.patch
- diff --git a/.gitignore b/.gitignore
- index 018a3de..572f4cc 100644
- --- a/.gitignore
- +++ b/.gitignore
- @@ -2,3 +2,5 @@
- !PKGBUILD
- !.SRCINFO
- !.gitignore
- +!org.gnome.pkexec.zenmap.policy
- +!sudo_with_pkexec.patch
- \ No newline at end of file
- diff --git a/PKGBUILD b/PKGBUILD
- index 72caa61..33165a6 100644
- --- a/PKGBUILD
- +++ b/PKGBUILD
- @@ -30,7 +30,7 @@ makedepends=(
- 'python-wheel'
- )
- optdepends=(
- - 'gksu: start zenmap as root'
- + 'polkit: start zenmap as root'
- )
- _source_main() {
- @@ -41,10 +41,14 @@ _source_main() {
- source=(
- "$_pkgsrc.$_pkgext"::"https://nmap.org/dist/$_pkgsrc.$_pkgext"
- "$_pkgsrc.$_pkgext.asc"::"https://nmap.org/dist/sigs/$_pkgsrc.$_pkgext.asc"
- + "org.gnome.pkexec.zenmap.policy"
- + "sudo_with_pkexec.patch"
- )
- sha256sums=(
- 'SKIP'
- 'SKIP'
- + 'd9845824febba3e859543d8c47a6b52e97b9c98bce1e14f92d89ffa61716df6c'
- + 'd2c6812d4aacb9dd361cbc3e0eab42aec04cf2acad9eb28be767f510170aded7'
- )
- validpgpkeys=(
- '436D66AB9A798425FDA0E3F801AF9F036B9355D0' # Nmap Project Signing Key (http://www.insecure.org/)
- @@ -59,18 +63,32 @@ pkgver() {
- fi
- }
- +prepare() {
- + cd "$_pkgsrc/zenmap"
- + # fix running as root via polkit https://github.com/nmap/nmap/pull/1172/
- + patch -p1 -i "$srcdir/sudo_with_pkexec.patch"
- +}
- +
- build() {
- cd "$_pkgsrc/zenmap"
- python -m build --no-isolation --wheel
- }
- package() {
- + install -Dm644 "org.gnome.pkexec.zenmap.policy" "$pkgdir/usr/share/polkit-1/actions/org.gnome.pkexec.zenmap.policy" #polkit policy
- +
- cd "$_pkgsrc"
- install -Dm644 "docs/zenmap.1" -t "$pkgdir/usr/share/man/man1/"
- install -Dm755 "LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"
- cd zenmap
- python -m installer --destdir="$pkgdir" dist/*.whl
- + install -Dm644 "zenmapCore/data/pixmaps/zenmap.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
- +
- + cd install_scripts/unix
- + install -Dm755 "su-to-zenmap.sh" "$pkgdir/usr/bin/su-to-zenmap.sh"
- + install -Dm644 "zenmap.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
- + install -Dm644 "zenmap-root.desktop" "$pkgdir/usr/share/applications/$pkgname-root.desktop"
- ln -s zenmap "$pkgdir/usr/bin/nmapfe"
- ln -s zenmap "$pkgdir/usr/bin/xnmap"
- diff --git a/org.gnome.pkexec.zenmap.policy b/org.gnome.pkexec.zenmap.policy
- new file mode 100644
- index 0000000..82bd2d2
- --- /dev/null
- +++ b/org.gnome.pkexec.zenmap.policy
- @@ -0,0 +1,19 @@
- +<?xml version="1.0" encoding="UTF-8"?>
- +<!DOCTYPE policyconfig PUBLIC
- + "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
- + "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
- +<policyconfig>
- +
- + <action id="com.gnome.pkexec.zenmap">
- + <message gettext-domain="zenmap">Authentication is required to run zenmap</message>
- + <icon_name>zenmap</icon_name>
- + <defaults>
- + <allow_any>auth_admin</allow_any>
- + <allow_inactive>auth_admin</allow_inactive>
- + <allow_active>auth_admin</allow_active>
- + </defaults>
- + <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/zenmap</annotate>
- + <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
- + </action>
- +
- +</policyconfig>
- diff --git a/sudo_with_pkexec.patch b/sudo_with_pkexec.patch
- new file mode 100644
- index 0000000..41a26fc
- --- /dev/null
- +++ b/sudo_with_pkexec.patch
- @@ -0,0 +1,18 @@
- +--- a/install_scripts/unix/su-to-zenmap.sh 2025-08-03 23:18:53.828345879 -0300
- ++++ b/install_scripts/unix/su-to-zenmap.sh 2025-08-03 21:46:19.889623182 -0300
- +@@ -40,6 +40,8 @@
- + else
- + SU_TO_ROOT_X=sterm
- + fi;
- ++ elif which pkexec>/dev/null 2>&1 ;then
- ++ SU_TO_ROOT_X=pkexec
- + else
- + SU_TO_ROOT_X=su-to-root
- + fi
- +@@ -52,6 +54,7 @@
- + # As a last resort, open a new xterm use sudo/su
- + sdterm) xterm -e "sudo -u $PRIV $COMMAND";;
- + sterm) xterm -e "su -l $PRIV -c $COMMAND";;
- ++ pkexec) pkexec "$COMMAND";;
- + esac;
- + fi
- --
- 2.50.1
Advertisement
Add Comment
Please, Sign In to add comment