From owner-freebsd-questions@freebsd.org Fri Aug 9 14:26:07 2019 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 230ACCA57E for ; Fri, 9 Aug 2019 14:26:07 +0000 (UTC) (envelope-from lee@adminart.net) Received: from mo6-p01-ob.smtp.rzone.de (mo6-p01-ob.smtp.rzone.de [IPv6:2a01:238:20a:202:5301::11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "*.smtp.rzone.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464nbf0qsjz4d8s for ; Fri, 9 Aug 2019 14:26:05 +0000 (UTC) (envelope-from lee@adminart.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1565360764; s=strato-dkim-0002; d=adminart.net; h=References:Message-ID:Date:In-Reply-To:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=QKs0489oBsG+nHKHpYQGJX7suyvtzotivu0JhxtZs0M=; b=TJJvPMwv507XmY4pUehH9OFwlTT3y8JpNQ3g6m2+YuD3nQued82Fpg1Alz4Aci2IWi a628n2xJEp7B/omCN963DCwFWU/QdyiiXj+9AMeJSCgYOeMlV6eGmhXRag34KTTDJduE JZ310qb9tHfyPSKeXc0+4r8F5gLGhRlson9SNDSoXRBm0xQBEHkf2/75sAeYAzq37Aun hR41LWV/J7Ya3LlMwPZKybukhtdmImgTkXccmDE5GgXRAsYI5PDuFju/a3xoXTF32mxa PkphXFYs/iLjAI2NHuBi2IXQKKDQDOvMbwkPXd9bmGjs96a515t/qAvp92O3suJ4LeC+ g+6A== X-RZG-AUTH: ":O2kGeEG7b/pS1FS4THaxjVF9w0vVgfQ9xGcjwO5WMRo5c+h5ceMqQWZ3yrBp+ARdaXvxIDf7nlw=" X-RZG-CLASS-ID: mo00 Received: from himinbjorg.adminart.net by smtp.strato.de (RZmta 44.24 DYNA|AUTH) with ESMTPSA id e0059dv79EQ2w7f (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Fri, 9 Aug 2019 16:26:02 +0200 (CEST) Received: from toy.adminart.net ([192.168.3.55]) by himinbjorg.adminart.net with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hw5qD-0001UG-EP; Fri, 09 Aug 2019 16:26:01 +0200 Received: from lee by toy.adminart.net with local (Exim 4.92) (envelope-from ) id 1hw5qD-00008L-CT; Fri, 09 Aug 2019 16:26:01 +0200 From: hw To: Polytropon Cc: Erich Dollansky , freebsd-questions@freebsd.org, hw Subject: Re: howto allow anyone to poweroff? In-Reply-To: <20190808085222.77febec0.freebsd@edvax.de> (Polytropon's message of "Thu, 8 Aug 2019 08:52:22 +0200") Date: Fri, 09 Aug 2019 15:24:33 +0200 Organization: my virtual residence Message-ID: <87sgqaxyi6.fsf@toy.adminart.net> References: <20190807183735.f4a87306c851426be6b799ca@gc-24.de> <20190808094618.787a7422.freebsd.ed.lists@sumeritec.com> <20190808085222.77febec0.freebsd@edvax.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 464nbf0qsjz4d8s X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=adminart.net header.s=strato-dkim-0002 header.b=TJJvPMwv; dmarc=none; spf=none (mx1.freebsd.org: domain of lee@adminart.net has no SPF policy when checking 2a01:238:20a:202:5301::11) smtp.mailfrom=lee@adminart.net X-Spamd-Result: default: False [-2.82 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[adminart.net:s=strato-dkim-0002]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[adminart.net]; HAS_ORG_HEADER(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[adminart.net:+]; NEURAL_HAM_SHORT(-0.95)[-0.948,0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[hw@adminart.net,lee@adminart.net]; RCVD_IN_DNSWL_LOW(-0.10)[1.1.0.0.0.0.0.0.0.0.0.0.1.0.3.5.2.0.2.0.a.0.2.0.8.3.2.0.1.0.a.2.list.dnswl.org : 127.0.5.1]; SUBJECT_ENDS_QUESTION(1.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6724, ipnet:2a01:238::/32, country:DE]; FROM_NEQ_ENVFROM(0.00)[hw@adminart.net,lee@adminart.net]; IP_SCORE(-0.77)[ipnet: 2a01:238::/32(-3.40), asn: 6724(-0.46), country: DE(-0.01)] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Aug 2019 14:26:07 -0000 Polytropon writes: > On Thu, 8 Aug 2019 09:46:18 +0800, Erich Dollansky wrote: >> Hi, >> >> On Wed, 7 Aug 2019 18:37:35 +0200 >> hw wrote: >> >> > Hi, >> > >> > is there a way to allow ordinary users to poweroff a machine? I'd >> > like to automatically poweroff PXE booted clients once the user that >> > was logged in logs out after using it. >> >> an unconventional way would be to have a cron job checking if someone >> is locked in an power off the machine if none is logged in. You do not >> have problems with the access rights but might run into the problem >> that the machine shutsdown when somebody just has arrived at the >> machine. >> >> You also can catch the logout event and shut the machine down then. It >> is the problem with the access right again. > > TO extend this idea, you could parse the output of programs > like "w" to check for reamining interactive users. If the > last one has logged out in a cron-controlled specific time > window, the system could perform a shutdown. Hoewever, the > problem described above will remain. :-) Hm. The diskless clients are very unlikely to ever have more than a single user, and a lost user who isn't using the machine shouldn't prevent it from shutting down after all users using it have logged out. Shutting down the machine right away when the user has logged out is probably not a good idea because someone else (not so likely) or the same user (more likely) might want to log in again right away. Or it may be a great idea because chances are that the user wanted to relog because of some issue they are hoping to fix by relogging, in which case it can be best to shutdown before allowing them to log in again. However, they could decide that for themselves if the waiting time before the shutdown is short (or press Ctrl+Alt+Del). So how do I make it so that after maybe 3 minutes the user which has used an X session has logged out, the machine shuts down? The shell of the user is set to startx, and I don't want to poll like every 3 minutes if xfreerdp is still running ... There is also the question how to shut down the machine after it has not been used for a while, like an hour or so, while the user is still logged in. In any case, when a user logs out, there is no way to shut down the machine other than holding the power button or pulling the plug, and that sucks. So far, I have only a startup script that initiates a shutdown after 500 minutes and am thinking to change it to a fixed time of day.