1238438Sdteske#!/bin/sh 2238438Sdteske#- 3238438Sdteske# Copyright (c) 2012 Ron McDowell 4263150Sdteske# Copyright (c) 2012-2014 Devin Teske 5238438Sdteske# All rights reserved. 6238438Sdteske# 7238438Sdteske# Redistribution and use in source and binary forms, with or without 8238438Sdteske# modification, are permitted provided that the following conditions 9238438Sdteske# are met: 10238438Sdteske# 1. Redistributions of source code must retain the above copyright 11238438Sdteske# notice, this list of conditions and the following disclaimer. 12238438Sdteske# 2. Redistributions in binary form must reproduce the above copyright 13238438Sdteske# notice, this list of conditions and the following disclaimer in the 14238438Sdteske# documentation and/or other materials provided with the distribution. 15238438Sdteske# 16238438Sdteske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17238438Sdteske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18238438Sdteske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19238438Sdteske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20238438Sdteske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21238438Sdteske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22238438Sdteske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23238438Sdteske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24238438Sdteske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25238438Sdteske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26238438Sdteske# SUCH DAMAGE. 27238438Sdteske# 28238438Sdteske# $FreeBSD: releng/11.0/usr.sbin/bsdconfig/usermgmt/useredit 263150 2014-03-14 03:42:05Z dteske $ 29238438Sdteske# 30238438Sdteske############################################################ INCLUDES 31238438Sdteske 32240684SdteskeBSDCFG_SHARE="/usr/share/bsdconfig" 33240684Sdteske. $BSDCFG_SHARE/common.subr || exit 1 34244675Sdteskef_dprintf "%s: loading includes..." "$0" 35240684Sdteskef_include $BSDCFG_SHARE/dialog.subr 36240684Sdteskef_include $BSDCFG_SHARE/mustberoot.subr 37263150Sdteskef_include $BSDCFG_SHARE/usermgmt/user.subr 38240684Sdteskef_include $BSDCFG_SHARE/usermgmt/user_input.subr 39238438Sdteske 40240684SdteskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt" 41238438Sdteskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 42238438Sdteske 43259054Sdteskef_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm && 44259054Sdteske pgm="${ipgm:-$pgm}" 45238438Sdteske 46238438Sdteske############################################################ MAIN 47238438Sdteske 48238438Sdteske# Incorporate rc-file if it exists 49238438Sdteske[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" 50238438Sdteske 51238438Sdteske# 52238438Sdteske# Process command-line arguments 53238438Sdteske# 54250633Sdteskewhile getopts h$GETOPTS_STDARGS flag; do 55238438Sdteske case "$flag" in 56252178Sdteske h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;; 57238438Sdteske esac 58238438Sdteskedone 59238438Sdteskeshift $(( $OPTIND - 1 )) 60238438Sdteske 61238438Sdteske# 62238438Sdteske# Initialize 63238438Sdteske# 64238438Sdteskef_dialog_title "$msg_edit_view $msg_login" 65238438Sdteskef_dialog_backtitle "${ipgm:+bsdconfig }$pgm" 66238438Sdteskef_mustberoot_init 67238438Sdteske 68238438Sdteske# 69263150Sdteske# If given a user name, operate on it and exit 70238438Sdteske# 71263150Sdteskeif [ "$1" ]; then 72263150Sdteske f_user_edit "$1" 73263150Sdteske exit $SUCCESS 74263150Sdteskefi 75263150Sdteske 76263150Sdteske# 77263150Sdteske# Present a list of users and loop until user Exits, Cancels or presses ESC 78263150Sdteske# 79263150Sdteskedefaultitem= 80238438Sdteskewhile :; do 81249751Sdteske f_dialog_menu_user_list "$defaultitem" 82238438Sdteske retval=$? 83251236Sdteske f_dialog_menutag_fetch mtag 84244550Sdteske f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" 85249751Sdteske defaultitem="$mtag" 86238438Sdteske 87256181Sdteske [ $retval -eq $DIALOG_OK ] || f_die 88238438Sdteske 89252019Sdteske [ "$mtag" = "X $msg_exit" ] && break 90252019Sdteske 91252019Sdteske # Anything else is a userid 92252019Sdteske 93263150Sdteske f_user_edit "$mtag" 94238438Sdteskedone 95238438Sdteske 96238438Sdteskeexit $SUCCESS 97238438Sdteske 98238438Sdteske################################################################################ 99238438Sdteske# END 100238438Sdteske################################################################################ 101