From bba90b333e64c334178ccee6c39fc36f2290d2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20T=2E=20Colombini=20G=C3=B3mez?= Date: Thu, 16 Oct 2014 08:51:18 +0200 Subject: [PATCH] =?UTF-8?q?Users=20=09-=20Se=20ha=20a=C3=B1adido=20la=20ej?= =?UTF-8?q?ecuci=C3=B3n=20de=20un=20comando=20para=20crear=20el=20director?= =?UTF-8?q?io=20de=20usuario=20al=20cambiar=20la=20contrase=C3=B1a=20=09-?= =?UTF-8?q?=20N=C3=BAmero=20de=20versi=C3=B3n=20aumentado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configure.ac | 4 +++- data/account-menu.xml | 1 - data/users.glade | 4 ++-- debian/changelog | 2 +- src/users.vala | 41 ++++++++++++++++++++++++++++++++++++++--- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 36595a6..da6c1e2 100644 --- a/configure.ac +++ b/configure.ac @@ -66,11 +66,13 @@ AC_ARG_VAR([UNINSTALLED_DIR], [the directory of the uninstalled hedera project]) PKG_PROG_PKG_CONFIG +VALAFLAGS+=" --pkg posix " + if test $UNINSTALLED_DIR; then VALA_CHECK_MODULES(ACCOUNT, [gtk+-3.0]) ACCOUNT_CFLAGS+=-I$UNINSTALLED_DIR ACCOUNT_LIBS+=$UNINSTALLED_DIR/build/main/libhedera.la - VALAFLAGS+="$ACCOUNT_VALAFLAGS --pkg gvn --pkg sql --pkg db --pkg vn --vapidir $UNINSTALLED_DIR/build/vapi " + VALAFLAGS+="$ACCOUNT_VALAFLAGS --pkg gvn --pkg sql --pkg db --pkg vn --vapidir $UNINSTALLED_DIR/build/vapi" AC_SUBST(account_libdir, $libdir/hedera/module) AC_SUBST(account_datadir, $datadir/hedera/module) diff --git a/data/account-menu.xml b/data/account-menu.xml index 58876f5..a159c7c 100644 --- a/data/account-menu.xml +++ b/data/account-menu.xml @@ -15,4 +15,3 @@ - diff --git a/data/users.glade b/data/users.glade index 3247e14..f5578da 100644 --- a/data/users.glade +++ b/data/users.glade @@ -261,13 +261,13 @@ WHERE #link - + True False users-grid name - + True diff --git a/debian/changelog b/debian/changelog index 2212626..f619f07 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-account (1.0-7) UNRELEASED; urgency=low +hedera-account (1.0-8) UNRELEASED; urgency=low * Initial Release. diff --git a/src/users.vala b/src/users.vala index e8b7334..6b70d3d 100644 --- a/src/users.vala +++ b/src/users.vala @@ -21,10 +21,14 @@ public class Vn.Users : Vn.Form private unowned Gtk.Dialog password_dialog; private unowned Vn.Entry password_entry; private unowned Vn.Entry repeat_password; + private unowned Gtk.Entry user_entry; + private string password; + private Sql.Batch batch; public override void open () { password_entry = get ("password-entry") as Vn.Entry; + user_entry = get ("name-entry-widget") as Gtk.Entry; repeat_password = get ("repeat-password") as Vn.Entry; password_dialog = get ("password-dialog") as Gtk.Dialog; password_dialog.add_button (_("Cancel"), Gtk.ResponseType.CANCEL); @@ -62,8 +66,8 @@ public class Vn.Users : Vn.Form { if (response_id == Gtk.ResponseType.ACCEPT) { - var password = password_entry.value.get_string (), - repeat = repeat_password.value.get_string (); + password = password_entry.value.get_string (); + var repeat = repeat_password.value.get_string (); if (password == "") reset_dialog (_("The password can't be empty.")); @@ -71,7 +75,7 @@ public class Vn.Users : Vn.Form reset_dialog (_("Passwords do not match.")); else { - var batch = get ("password-batch") as Sql.Batch; + batch = get ("password-batch") as Sql.Batch; var query = "SELECT user_set_password (#user, #pass)"; conn.query_async (query, batch, on_password_changed); } @@ -96,5 +100,36 @@ public class Vn.Users : Vn.Form } catch {} + + conn.query_async ("SELECT ssh_user, ssh_host FROM account_config", + null, on_user_received); + } + + [CCode (instance_pos = -1)] + public void on_user_received (Db.Request request) + { + Db.Result result; + + try + { + result = request.fetch_result (); + } + catch + { + return; + } + + string user = user_entry.text; + + unowned Db.Row row = result.data.get (0); + string ssh_user = row.@value[0].get_string (); + string ssh_host = row.@value[1].get_string (); + + if (-1 == Posix.system + (@"ssh $ssh_user@$ssh_host " + +@"\"mkhomedir_helper $user " + +@"&& printf '$password\n$password\n' " + +@"| smbpasswd -a -s $user\"")) + warning ("User home directory creation failed."); } }