Advertisement
FlyFar

dev/make_diff_of_uncommitted_changes.sh

Aug 12th, 2023
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.96 KB | Cybersecurity | 0 0
  1. #!/bin/bash
  2. #
  3. # Copyright (C) 2017-2018  Joe Testa <jtesta@positronsecurity.com>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms version 3 of the GNU General Public License as
  7. # published by the Free Software Foundation.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. #
  17. #
  18. #
  19. # This script will apply the existing, committed patch to a new directory of
  20. # sources, then diff it with "openssh-7.5p1-mitm/".  The result is stored in
  21. # "uncommitted_changes.patch".
  22.  
  23. if [[ ! -f openssh-7.5p1.tar.gz ]]; then
  24.     echo -e "\nCan't find openssh-7.5p1.tar.gz.  Ensure that you're in the top level directory of the SSH MITM project."
  25.     exit -1
  26. fi
  27.  
  28. git diff-index HEAD | grep openssh-7.5p1-mitm.patch
  29. if [[ $? != 1 ]]; then
  30.     echo "Error: it appears that openssh-7.5p1-mitm.patch already has uncommitted changes!"
  31.     exit -1
  32. fi
  33.  
  34. rm -rf openssh-7.5p1-previous uncommitted_changes.patch
  35. tar xzf openssh-7.5p1.tar.gz
  36. mv openssh-7.5p1 openssh-7.5p1-previous
  37.  
  38. pushd openssh-7.5p1-previous > /dev/null
  39. patch -p1 < ../openssh-7.5p1-mitm.patch > /dev/null
  40. popd > /dev/null
  41.  
  42. pushd openssh-7.5p1-mitm > /dev/null
  43. make clean > /dev/null
  44. popd > /dev/null
  45.  
  46. diff -ru --new-file -x '*~' -x 'config.*' -x Makefile -x opensshd.init -x survey.sh -x openssh.xml -x buildpkg.sh -x output.0 -x requests -x traces.0 -x configure openssh-7.5p1-previous openssh-7.5p1-mitm/ > uncommitted_changes.patch
  47.  
  48. if [[ -f uncommitted_changes.patch ]]; then
  49.     echo -e "\nuncommitted_changes.patch created."
  50. else
  51.     echo -e "\nFailed to create uncommitted_changes.patch."
  52. fi
  53.  
  54. rm -rf openssh-7.5p1-previous
  55. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement