From owner-freebsd-questions@freebsd.org Fri Feb 19 10:57:40 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9114DAAEC13 for ; Fri, 19 Feb 2016 10:57:40 +0000 (UTC) (envelope-from export.toprank@gmail.com) Received: from mail-ig0-x24e.google.com (mail-ig0-x24e.google.com [IPv6:2607:f8b0:4001:c05::24e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 60D821622 for ; Fri, 19 Feb 2016 10:57:40 +0000 (UTC) (envelope-from export.toprank@gmail.com) Received: by mail-ig0-x24e.google.com with SMTP id zh17so76023igc.1 for ; Fri, 19 Feb 2016 02:57:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:message-id:date:subject:from:to:content-type; bh=ceJO8jdps55Vpdux57c6B4XUxuce+RBmSXKbCCk8tUA=; b=Utt5yL3qqg578w/R4p41XyRWT9/i12566pmpfPjQ6Iccbq5O7Clv4QMwPDTu2ckhE8 xeLEavy/33Dmn0S6ESuYGPesUNXV35ZFFmUvSW8aTKu4U8q4EgK7zfLoWG4GFHwJueae 0BwXB6pnD69/A6dqF12ChmXjDxvrTSJVcWwEMicTMAZZuJrGgQOCZP5UWAohZzfnmWWR G5medDqw+pJGKcYFxc5O5ECF5zDCj9YsBp3qSTMd2meYLaW0a6rksS+ZjO9wtWG7ChnY qQpp7OZ2Vzn1TiNNeSpAAbip2fv0Wjt/I46ZmMgJ9GmMyWb32p2bBIfsx61TJznkh+5l 3Leg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:message-id:date:subject:from:to :content-type; bh=ceJO8jdps55Vpdux57c6B4XUxuce+RBmSXKbCCk8tUA=; b=l0oNPz+kKmoVOIf5LnNfv52rpmWBDBHiiP/f58fGuUh36bwOtm4buwRQbfqGG2Mz03 XQRBBx7esBmDKZzIa6XNH/M8jiE8Wv51cE5tOzuGoBhbT/T4zpA30pClAX+f8vmQgiRD 82QtFcLW0fUWGWulE7PgzCeoCLALywTAiHEXSbSWxsumveAFN/sVjArc5PsDCXq7NY/z 9i7zXuOgGnBHGc/sZgAXRZYQHRilGWG/khPWARPYS5VDviTqXY7AHX0G8zDc5jpnMtAZ h4+9AXWQgi+HUGkzASOwu7fdwwX7NYU9/Rn7Rzn/6lxrWxxHxiYzn9+y+oQv2kBEBXxn Rj9A== X-Gm-Message-State: AG10YOSPc+37Gog3gtAv2AY2ZEjvs+hjvnKAWeLVFK6nuvmz8RSbfTTcNGBynsElU8djQKd1DrUC MIME-Version: 1.0 X-Received: by 10.50.164.134 with SMTP id yq6mr7716129igb.13.1455879459704; Fri, 19 Feb 2016 02:57:39 -0800 (PST) Message-ID: <089e01229ed208178c052c1d5ab1@google.com> Date: Fri, 19 Feb 2016 10:57:39 +0000 Subject: Sub-3D CAD Services - India From: Donald Kevin To: freebsd-questions@FreeBSD.org, freebsd-doc@FreeBSD.org Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes Content-Transfer-Encoding: base64 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Feb 2016 10:57:40 -0000 DQoqRGVhciBvd25lciBvZiBGcmVlYnNkLm9yZywqDQoNCipJIGFtIERvbmFsZCBLZXZpbi1CdXNp bmVzcyBNYW5hZ2VyIGZvciBDQUQgM0QgTW9kZWwgQ29tcGFueSBsb2NhdGVkIGluDQpJbmRpYS5P dXIgQ29tcGFueSBk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ailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33220AAD264 for ; Fri, 19 Feb 2016 11:14:41 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C97331F24 for ; Fri, 19 Feb 2016 11:14:40 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de (port-92-195-96-7.dynamic.qsc.de [92.195.96.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 4F0093CE5E; Fri, 19 Feb 2016 12:05:04 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id u1JB537T002177; Fri, 19 Feb 2016 12:05:03 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Fri, 19 Feb 2016 12:05:03 +0100 From: Polytropon To: Yudi V Cc: freebsd-questions@freebsd.org Subject: Re: minimize use of root account Message-Id: <20160219120503.fc97ef10.freebsd@edvax.de> In-Reply-To: References: Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Feb 2016 11:14:41 -0000 On Fri, 19 Feb 2016 16:29:43 +1100, Yudi V wrote: > Hi all, > > currently I use the below script to load geli devices and import zpool. It > needs to be run as root. > how to run this script as normal user, is there a group that the user needs > to be part of? No, not for this task. There are different ways to do it. 1. You can set the script itself to "run as root" (chmod +s) when the script is owned by root:root. Regular users may then execute it. 2. Temporarily become root by using "su -" or ("su -m" if preferred) and execute the script. See "man su" for details. 3. Use a tool like "sudo" or "super". This is probably the better approach: "sudo ". You need to install the program from ports / packages, it's not part of the OS. You could include the "sudo " parts into the script as well, but that's probably not good practice. In order to "su root", your user needs to be part of the "wheel" group. Regular users are not permitted this increase of power. :-) > also when I have to shutdown/reboot, I need to run the command as root but > instead would like for the normal user to be able to shutdown and reboot. Make your user part of the "operator" group to be able to execute the "shutdown -p" and "shutdown -r" commands. Note that the "reboot" command may only be executed by root. > I posted this first on the forums but did not receive any relevant ans > yet. https://forums.freebsd.org/threads/55166/ > > appreciate if someone can answer my questions. > Code: > > ############### > #!/bin/csh -f Why?! There's a relevant article: "Csh Programming Considered Harmful" written by Tom Christiansen. https://www-uxsup.csx.cam.ac.uk/misc/csh.html I have written one (!) csh script and I still regret it, maybe because it still works. :-) On FreeBSD, the default shell script interpreter is /bin/sh. How about this? #!/bin/sh # attach geli containers geli attach /dev/label/dataE0 if [ $? -eq 0 ]; then geli attach /dev/label/dataE1 if [ $? -eq 0 ]; then # import zpool tank3 (on a 2-way mirror) zpool import tank3 # mount zfs datasets from tank3 zfs mount -a # start samba service samba_server restart else geli detach /dev/label/dataE0.eli echo "detached dataE0.eli" echo "failed to attach dataE1.eli, check your password." fi else echo "failed to attach dataE0.eli, check your password." fi There are probably more pleasant ways for the "error checking cascade". Indentation helps a lot. The "else" and "fi" appear in the same column like the "if" where they belong to; the "conditioned commands" are indented. Quotes around strings. Empty lines also increase readablilty. Just in case you might want to debug the script at some time, maybe 10 years in the future... ;-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...