commit e59072ee5301a9d9722f6d26ce78338697a5d7f9 Author: luisgulo Date: Sun Jun 4 16:47:17 2023 +0200 Subida a GITEA diff --git a/.directory b/.directory new file mode 100644 index 0000000..06dab1c --- /dev/null +++ b/.directory @@ -0,0 +1,2 @@ +[Desktop Entry] +Icon=./.icon.png diff --git a/.gambas/FMAIN b/.gambas/FMAIN new file mode 100644 index 0000000..656d68d Binary files /dev/null and b/.gambas/FMAIN differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.hidden/CHANGELOG b/.hidden/CHANGELOG new file mode 100644 index 0000000..7b11e57 --- /dev/null +++ b/.hidden/CHANGELOG @@ -0,0 +1,3 @@ +* Tue Aug 17 2021 luisgulo 1.0.1 +- Lanzamiento inicial + diff --git a/.icon.png b/.icon.png new file mode 100644 index 0000000..e70d7c1 Binary files /dev/null and b/.icon.png differ diff --git a/.project b/.project new file mode 100644 index 0000000..b3da6b3 --- /dev/null +++ b/.project @@ -0,0 +1,25 @@ +# Gambas Project File 3.0 +Title=ajustarsudo +Startup=FMain +Icon=sudo.png +Version=1.0.1 +Component=gb.image +Component=gb.gui +Component=gb.form +Description="Ajustar SUDO para el usuario actual.\nSolo se permite si conoce la clave de root" +Authors="luisgulo@soloconlinux.org.es" +TabSize=2 +Language=es_ES +SourcePath=/home/luisgulo/ProyectosGAMBAS/SOURCEs +Maintainer=luisgulo +Vendor=SoloConLinux +Address=luisgulo@gmail.com +Url=https://repositorio.soloconlinux.org.es +License=General Public License +PackageName=ajustarsudo-1.0.1 +CreateEachDirectory=1 +Packager=1 +Systems=debian +Menus=debian:"Applications/System/Administration" +Categories=debian:"System" +Groups=debian:"admin" diff --git a/.settings b/.settings new file mode 100644 index 0000000..ce93749 --- /dev/null +++ b/.settings @@ -0,0 +1,23 @@ +[Breakpoints] +Count=0 + +[DebugWindow] +Count=0 + +[Executable] +DoNotIncrementVersion=False +NoTestModule=False +Path="AjustarSudo.gambas" + +[OpenFile] +File[1]=".src/FMain.form" +Active=2 +File[2]=".src/FMain.class:0.14" +Count=2 + +[Package] +Dir="~/ProyectosGAMBAS/INSTALADOR/AjustarSudo/" + +[Watches] +Count=0 + diff --git a/.src/FMain.class b/.src/FMain.class new file mode 100644 index 0000000..3dac691 --- /dev/null +++ b/.src/FMain.class @@ -0,0 +1,47 @@ +' Gambas class file + + +Public Sub Form_Open() + ' Cargamos usuario actual + txtUsuario.Text = System.User.Name + System.Shell = "/bin/bash" +End + +Public Sub btnSalir_Click() + Quit +End + +Public Sub btnAjustarSudo_Click() + Dim txtAccion As String + Message.Title = Me.Text + ' Comprobar Clave ROOT + If IsNull(txtClaveRoot.Text) Then + ' Clave Vacia + + Message.Error("Error: Debe de escribir la clave de 'root'" & gb.crlf & "La clave no puede estar vacia") + Else + ' Clave introducida + If SudoComodo.Value Then + ' Ajustar sudo en modo Cómodo + txtAccion = "SUDO COMODO" + 'Shell "echo '" & txtUsuario.Text & " ALL = (ALL) NOPASSWD: ALL' > /tmp/autorizado_" & txtUsuario.Text + 'Shell "echo -n '" & txtClaveRoot.Text & "' |su -c 'cp /tmp/autorizado_" & txtUsuario.Text & " /tmp/kk/'" + Shell "echo -n '" & txtClaveRoot.Text & "' |su -c 'echo " & txtUsuario.Text & " ALL = \\(ALL\\) NOPASSWD: ALL > /etc/sudoers.d/autorizado_" & txtUsuario.Text & "'" + Endif + If SudoSeguro.Value Then + ' Ajustar sudo en modo Seguro + txtAccion = "SUDO SEGURO" + 'Shell "echo '" & txtUsuario.Text & " ALL=(ALL:ALL) ALL' > /tmp/autorizado_" & txtUsuario.Text + 'Shell "echo -n '" & txtClaveRoot.Text & "' |su -c 'cp /tmp/autorizado_" & txtUsuario.Text & " /tmp/kk/'" + Shell "echo -n '" & txtClaveRoot.Text & "' |su -c 'echo " & txtUsuario.Text & " ALL=\\(ALL:ALL\\) ALL > /etc/sudoers.d/autorizado_" & txtUsuario.Text & "'" + Endif + If SinSudo.Value Then + 'Eliminar SUDO + txtAccion = "SIN SUDO" + Shell "echo -n '" & txtClaveRoot.Text & "' |su -c 'echo \\# Usuario sin SUDO > /etc/sudoers.d/autorizado_" & txtUsuario.Text & "'" + Endif + Message.Info("Configurado " & txtAccion & " para " & txtUsuario.Text) + Quit + Endif + +End diff --git a/.src/FMain.class~ b/.src/FMain.class~ new file mode 100644 index 0000000..6e9dfdb --- /dev/null +++ b/.src/FMain.class~ @@ -0,0 +1,48 @@ +' Gambas class file + + +Public Sub Form_Open() + ' Cargamos usuario actual + txtUsuario.Text = System.User.Name + System.Shell = "/bin/bash" +End + +Public Sub btnSalir_Click() + Quit +End + +Public Sub btnAjustarSudo_Click() + Dim SalidaShell As String + Dim txtAccion As String + Message.Title = Me.Text + ' Comprobar Clave ROOT + If IsNull(txtClaveRoot.Text) Then + ' Clave Vacia + + Message.Error("Error: Debe de escribir la clave de 'root'" & gb.crlf & "La clave no puede estar vacia") + Else + ' Clave introducida + If SudoComodo.Value Then + ' Ajustar sudo en modo Cómodo + txtAccion = "SUDO COMODO" + 'Shell "echo '" & txtUsuario.Text & " ALL = (ALL) NOPASSWD: ALL' > /tmp/autorizado_" & txtUsuario.Text + 'Shell "echo -n '" & txtClaveRoot.Text & "' |su -c 'cp /tmp/autorizado_" & txtUsuario.Text & " /tmp/kk/'" + Shell "echo -n '" & txtClaveRoot.Text & "' |su -c 'echo " & txtUsuario.Text & " ALL = \\(ALL\\) NOPASSWD: ALL > /etc/sudoers.d/autorizado_" & txtUsuario.Text & "'" + Endif + If SudoSeguro.Value Then + ' Ajustar sudo en modo Seguro + txtAccion = "SUDO SEGURO" + 'Shell "echo '" & txtUsuario.Text & " ALL=(ALL:ALL) ALL' > /tmp/autorizado_" & txtUsuario.Text + 'Shell "echo -n '" & txtClaveRoot.Text & "' |su -c 'cp /tmp/autorizado_" & txtUsuario.Text & " /tmp/kk/'" + Shell "echo -n '" & txtClaveRoot.Text & "' |su -c 'echo " & txtUsuario.Text & " ALL=\\(ALL:ALL\\) ALL > /etc/sudoers.d/autorizado_" & txtUsuario.Text & "'" + Endif + If SinSudo.Value Then + 'Eliminar SUDO + txtAccion = "SIN SUDO" + Shell "echo -n '" & txtClaveRoot.Text & "' |su -c 'echo \\# Usuario sin SUDO > /etc/sudoers.d/autorizado_" & txtUsuario.Text & "'" + Endif + Message.Info("Configurado " & txtAccion & " para " & txtUsuario.Text) + Quit + Endif + +End diff --git a/.src/FMain.form b/.src/FMain.form new file mode 100644 index 0000000..0902597 --- /dev/null +++ b/.src/FMain.form @@ -0,0 +1,41 @@ +# Gambas Form File 3.0 + +{ Form Form + MoveScaled(0,0,50,39) + Text = ("Ajustar SUDO") + Icon = Picture["sudo.png"] + { txtClaveRoot TextBox + MoveScaled(24,9,24,4) + Password = True + } + { SudoComodo RadioButton + MoveScaled(2,15,46,4) + Text = ("Sudo Cómodo (sin pedir contraseña)") + Value = True + } + { SudoSeguro RadioButton + MoveScaled(2,20,46,4) + Text = ("Sudo Seguro (pide clave siempre)") + } + { SinSudo RadioButton + MoveScaled(2,25,46,4) + Text = ("Quitar Sudo a mi usuario") + } + { btnAjustarSudo Button + MoveScaled(20,32,28,4) + Text = ("Ajustar SUDO a mi usuario") + } + { btnSalir Button + MoveScaled(2,32,16,4) + Text = ("Salir") + } + { txtUsuario TextLabel + MoveScaled(2,3,46,4) + Border = Border.Plain + } + { lblClaveRoot TextLabel + MoveScaled(2,9,21,4) + Text = ("Escriba clave de root:") + Alignment = Align.Center + } +} diff --git a/.src/FMain.form~ b/.src/FMain.form~ new file mode 100644 index 0000000..07aab4a --- /dev/null +++ b/.src/FMain.form~ @@ -0,0 +1,41 @@ +# Gambas Form File 3.0 + +{ Form Form + MoveScaled(0,0,50,39) + Text = ("Ajustar SUDO") + Icon = Picture["icon:/22/linux"] + { txtClaveRoot TextBox + MoveScaled(24,9,24,4) + Password = True + } + { SudoComodo RadioButton + MoveScaled(2,15,46,4) + Text = ("Sudo Cómodo (sin pedir contraseña)") + Value = True + } + { SudoSeguro RadioButton + MoveScaled(2,20,46,4) + Text = ("Sudo Seguro (pide clave siempre)") + } + { SinSudo RadioButton + MoveScaled(2,25,46,4) + Text = ("Quitar Sudo a mi usuario") + } + { btnAjustarSudo Button + MoveScaled(20,32,28,4) + Text = ("Ajustar SUDO a mi usuario") + } + { btnSalir Button + MoveScaled(2,32,16,4) + Text = ("Salir") + } + { txtUsuario TextLabel + MoveScaled(2,3,46,4) + Border = Border.Plain + } + { lblClaveRoot TextLabel + MoveScaled(2,9,21,4) + Text = ("Escriba clave de root:") + Alignment = Align.Center + } +} diff --git a/.startup b/.startup new file mode 100644 index 0000000..eac771c --- /dev/null +++ b/.startup @@ -0,0 +1,10 @@ +FMain +ajustarsudo +0 +0 +1.0.1 + +gb.image +gb.gui +gb.form + diff --git a/AjustarSudo.gambas b/AjustarSudo.gambas new file mode 100755 index 0000000..25a2e5a Binary files /dev/null and b/AjustarSudo.gambas differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/sudo.png b/sudo.png new file mode 100644 index 0000000..503babe Binary files /dev/null and b/sudo.png differ