diff --git a/actions/check-user-exists b/actions/check-user-exists new file mode 100755 index 000000000..b056d453b --- /dev/null +++ b/actions/check-user-exists @@ -0,0 +1,28 @@ +#!/bin/sh +# +# This file is part of Plinth. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +# Can be run as normal user. + +username="$1" + +getent passwd "$username" >/dev/null +if [ $? -eq 0 ]; then + echo "User exists" +else + echo "User does not exist" +fi diff --git a/plinth/modules/users/templates/users_update.html b/plinth/modules/users/templates/users_update.html index 4a817e1af..cbd5bde40 100644 --- a/plinth/modules/users/templates/users_update.html +++ b/plinth/modules/users/templates/users_update.html @@ -46,6 +46,11 @@ {{ form|bootstrap }} + {% if is_posix_user %} +

This user is also a POSIX user and (if active) can log in to the + system through SSH.

+ {% endif %} + diff --git a/plinth/modules/users/views.py b/plinth/modules/users/views.py index 21b841cb2..e070b1e71 100644 --- a/plinth/modules/users/views.py +++ b/plinth/modules/users/views.py @@ -26,6 +26,7 @@ from django.views.generic import ListView from gettext import gettext as _ from .forms import CreateUserForm, UserUpdateForm, UserChangePasswordForm +from plinth import actions subsubmenu = [{'url': reverse_lazy('users:index'), @@ -70,6 +71,12 @@ class UserUpdate(ContextMixin, SuccessMessageMixin, UpdateView): success_message = _('User %(username)s updated.') title = _('Edit User') + def get_context_data(self, **kwargs): + context = super(UserUpdate, self).get_context_data(**kwargs) + output = actions.run('check-user-exists', [self.object.username]) + context['is_posix_user'] = 'User exists' in output + return context + def get_success_url(self): """Return the URL to redirect to in case of successful updation.""" return reverse('users:edit', kwargs={'slug': self.object.username})