maromalo

zenmap aur patch

Aug 3rd, 2025 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.51 KB | Source Code | 0 0
  1. From e7f5fcd53b1d997152a99b1418691e899557c346 Mon Sep 17 00:00:00 2001
  2. From: maromnztt <[email protected]>
  3. Date: Mon, 4 Aug 2025 01:26:06 -0300
  4. Subject: [PATCH] Patch run as root and add desktop files
  5.  
  6. ---
  7. .gitignore                     |  2 ++
  8.  PKGBUILD                       | 20 +++++++++++++++++++-
  9.  org.gnome.pkexec.zenmap.policy | 19 +++++++++++++++++++
  10.  sudo_with_pkexec.patch         | 18 ++++++++++++++++++
  11.  4 files changed, 58 insertions(+), 1 deletion(-)
  12.  create mode 100644 org.gnome.pkexec.zenmap.policy
  13.  create mode 100644 sudo_with_pkexec.patch
  14.  
  15. diff --git a/.gitignore b/.gitignore
  16. index 018a3de..572f4cc 100644
  17. --- a/.gitignore
  18. +++ b/.gitignore
  19. @@ -2,3 +2,5 @@
  20.  !PKGBUILD
  21.  !.SRCINFO
  22.  !.gitignore
  23. +!org.gnome.pkexec.zenmap.policy
  24. +!sudo_with_pkexec.patch
  25. \ No newline at end of file
  26. diff --git a/PKGBUILD b/PKGBUILD
  27. index 72caa61..33165a6 100644
  28. --- a/PKGBUILD
  29. +++ b/PKGBUILD
  30. @@ -30,7 +30,7 @@ makedepends=(
  31.    'python-wheel'
  32.  )
  33.  optdepends=(
  34. -  'gksu: start zenmap as root'
  35. +  'polkit: start zenmap as root'
  36.  )
  37.  
  38.  _source_main() {
  39. @@ -41,10 +41,14 @@ _source_main() {
  40.    source=(
  41.      "$_pkgsrc.$_pkgext"::"https://nmap.org/dist/$_pkgsrc.$_pkgext"
  42.      "$_pkgsrc.$_pkgext.asc"::"https://nmap.org/dist/sigs/$_pkgsrc.$_pkgext.asc"
  43. +    "org.gnome.pkexec.zenmap.policy"
  44. +    "sudo_with_pkexec.patch"
  45.    )
  46.    sha256sums=(
  47.      'SKIP'
  48.      'SKIP'
  49. +    'd9845824febba3e859543d8c47a6b52e97b9c98bce1e14f92d89ffa61716df6c'
  50. +    'd2c6812d4aacb9dd361cbc3e0eab42aec04cf2acad9eb28be767f510170aded7'
  51.    )
  52.    validpgpkeys=(
  53.      '436D66AB9A798425FDA0E3F801AF9F036B9355D0' # Nmap Project Signing Key (http://www.insecure.org/)
  54. @@ -59,18 +63,32 @@ pkgver() {
  55.    fi
  56.  }
  57.  
  58. +prepare() {
  59. +  cd "$_pkgsrc/zenmap"
  60. +  # fix running as root via polkit https://github.com/nmap/nmap/pull/1172/
  61. +  patch -p1 -i "$srcdir/sudo_with_pkexec.patch"
  62. +}
  63. +
  64.  build() {
  65.    cd "$_pkgsrc/zenmap"
  66.    python -m build --no-isolation --wheel
  67.  }
  68.  
  69.  package() {
  70. +  install -Dm644 "org.gnome.pkexec.zenmap.policy" "$pkgdir/usr/share/polkit-1/actions/org.gnome.pkexec.zenmap.policy" #polkit policy
  71. +
  72.    cd "$_pkgsrc"
  73.    install -Dm644 "docs/zenmap.1" -t "$pkgdir/usr/share/man/man1/"
  74.    install -Dm755 "LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"
  75.  
  76.    cd zenmap
  77.    python -m installer --destdir="$pkgdir" dist/*.whl
  78. +  install -Dm644 "zenmapCore/data/pixmaps/zenmap.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
  79. +
  80. +  cd install_scripts/unix
  81. +  install -Dm755 "su-to-zenmap.sh" "$pkgdir/usr/bin/su-to-zenmap.sh"
  82. +  install -Dm644 "zenmap.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
  83. +  install -Dm644 "zenmap-root.desktop" "$pkgdir/usr/share/applications/$pkgname-root.desktop"
  84.  
  85.    ln -s zenmap "$pkgdir/usr/bin/nmapfe"
  86.    ln -s zenmap "$pkgdir/usr/bin/xnmap"
  87. diff --git a/org.gnome.pkexec.zenmap.policy b/org.gnome.pkexec.zenmap.policy
  88. new file mode 100644
  89. index 0000000..82bd2d2
  90. --- /dev/null
  91. +++ b/org.gnome.pkexec.zenmap.policy
  92. @@ -0,0 +1,19 @@
  93. +<?xml version="1.0" encoding="UTF-8"?>
  94. +<!DOCTYPE policyconfig PUBLIC
  95. +  "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
  96. +  "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
  97. +<policyconfig>
  98. +
  99. +  <action id="com.gnome.pkexec.zenmap">
  100. +    <message gettext-domain="zenmap">Authentication is required to run zenmap</message>
  101. +    <icon_name>zenmap</icon_name>
  102. +    <defaults>
  103. +      <allow_any>auth_admin</allow_any>
  104. +      <allow_inactive>auth_admin</allow_inactive>
  105. +      <allow_active>auth_admin</allow_active>
  106. +    </defaults>
  107. +    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/zenmap</annotate>
  108. +    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
  109. +  </action>
  110. +
  111. +</policyconfig>
  112. diff --git a/sudo_with_pkexec.patch b/sudo_with_pkexec.patch
  113. new file mode 100644
  114. index 0000000..41a26fc
  115. --- /dev/null
  116. +++ b/sudo_with_pkexec.patch
  117. @@ -0,0 +1,18 @@
  118. +--- a/install_scripts/unix/su-to-zenmap.sh 2025-08-03 23:18:53.828345879 -0300
  119. ++++ b/install_scripts/unix/su-to-zenmap.sh 2025-08-03 21:46:19.889623182 -0300
  120. +@@ -40,6 +40,8 @@
  121. +         else
  122. +           SU_TO_ROOT_X=sterm
  123. +         fi;
  124. ++      elif which pkexec>/dev/null 2>&1 ;then
  125. ++        SU_TO_ROOT_X=pkexec
  126. +       else
  127. +         SU_TO_ROOT_X=su-to-root
  128. +       fi
  129. +@@ -52,6 +54,7 @@
  130. +   # As a last resort, open a new xterm use sudo/su
  131. +       sdterm) xterm -e "sudo -u $PRIV $COMMAND";;
  132. +       sterm) xterm -e "su -l $PRIV -c $COMMAND";;
  133. ++      pkexec) pkexec "$COMMAND";;
  134. +     esac;
  135. + fi
  136. --
  137. 2.50.1
  138.  
  139.  
Advertisement
Add Comment
Please, Sign In to add comment