OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.7 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../webmin/stone_mod_webmin.sh
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2003 Clifford Wolf
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- T2-COPYRIGHT-NOTE-END ---
  15. #
  16. # [MAIN] 80 webmin Webmin Configuration
  17. WEBMINDIR=/opt/webmin
  18. USERFILE=/etc/opt/webmin/miniserv.users
  19. CONFFILE=/etc/opt/webmin/miniserv.conf
  20. ACLFILE=/etc/opt/webmin/webmin.acl
  21. set_pw() {
  22. LOGIN="$1"
  23. PASSWORD=1
  24. PASSWORD2=2
  25. while [ "$PASSWORD" != "$PASSWORD2" ] ; do
  26. gui_input "Enter $LOGIN password" "" PASSWORD ;
  27. gui_input "Re-Enter $LOGIN password" "" PASSWORD2 ;
  28. if [ "$PASSWORD" != "$PASSWORD2" ] ; then
  29. gui_message "Passwords are different: no change!"
  30. fi
  31. done
  32. if [ "$2" = 1 ] ; then
  33. gui_message "Changeing $LOGIN password."
  34. tmp="`mktemp`"
  35. sed "/^$LOGIN:.*/ s/^$LOGIN:[^:]*:/$LOGIN:`perl -e 'print crypt($ARGV[0], "XX");' "$PASSWORD"`:/ ;" < $USERFILE > $tmp
  36. cat $tmp > $USERFILE ; rm -f $tmp
  37. else
  38. gui_message "Setting $LOGIN password."
  39. perl -e 'print "$ARGV[0]:",crypt($ARGV[1], "XX"),":0::\n"' "$LOGIN" "$PASSWORD" >> $USERFILE
  40. fi
  41. }
  42. set_acl() {
  43. LOGIN="$1"
  44. ALLMODS=`echo $WEBMINDIR/*/module.info | sed -e "s,$WEBMINDIR/,,g ; s,/module.info,,g"`
  45. if [ "$2" = 1 ] ; then
  46. gui_message "Resetting $LOGIN acls to default."
  47. tmp="`mktemp`"
  48. sed "/^$LOGIN:.*/ s/:.*/: $ALLMODS/ ;" < $ACLFILE > $tmp
  49. cat $tmp > $ACLFILE ; rm -f $tmp
  50. else
  51. gui_message "Setting $LOGIN acls to default."
  52. echo "$LOGIN: $ALLMODS" >> $ACLFILE
  53. fi
  54. }
  55. set_user() {
  56. gui_input "Enter user login" "admin" LOGIN ;
  57. if [ "`grep \"^$LOGIN:\" $USERFILE`" = "" ] ; then
  58. gui_message "New user $LOGIN !"
  59. set_pw $LOGIN 0
  60. set_acl $LOGIN 0
  61. else
  62. gui_message "Existing user $LOGIN !"
  63. if gui_yesno "Change $LOGIN password?" ; then
  64. set_pw $LOGIN 1
  65. fi
  66. if gui_yesno "Reset $LOGIN acls?" ; then
  67. set_acl $LOGIN 1
  68. fi
  69. fi
  70. }
  71. edit() {
  72. gui_edit "Edit file $1" "$1"
  73. exec $STONE webmin
  74. }
  75. main() {
  76. while
  77. cmd="gui_menu webmin 'Webmin Configuration - Select an item to'"
  78. cmd="$cmd 'Add/(Re-)Set user password and acls' 'set_user'"
  79. cmd="$cmd '' '' 'Configure runlevels for webmin service'"
  80. cmd="$cmd '$STONE runlevel edit_srv webmin'"
  81. cmd="$cmd '(Re-)Start webmin init script'"
  82. cmd="$cmd '$STONE runlevel restart webmin'"
  83. cmd="$cmd '' ''"
  84. cmd="$cmd 'View/Edit $CONFFILE file' 'edit $CONFFILE'"
  85. eval "$cmd"
  86. do : ; done
  87. }