Re: xdm halt & reboot buttons

2016-07-04 Thread Alexander Hall


On July 4, 2016 11:06:28 PM GMT+02:00, Alexander Hall  
wrote:
> 
>
>On July 4, 2016 5:51:06 PM GMT+02:00, Bob Beck 
>wrote:
>>>
>>> Thinking of it again, you could possibly just use the action
>>arguments for
>>> a more generic "execute-program" action.
>>>
>>
>>Ahhh.. are you insane? The way you get a generic "execute program"
>>action is to LOG IN TO THE DAMN MACHINE!
>
>Heh, I think I need to clarify myself, in that what I'm talking about
>is probably not obvious unless you actually read the code (if even
>then).
>
>The "generic" action would be how to internally solve adding the
>required functionality and bind it to a key or two. It would not be
>configurable by the user, but could be used by an admin to add any
>pre-authentication 

pre-authentication *action or command*

> he or she wishes, be it halt -p, zzz or *shrug*
>uptime. 
>
>That said, maybe this is handing out more than a reasonable amount of
>rope and ammo for hurting the system. 
>
>/Alexander 
>
>>
>>Why don't you guys just make an option so someone can set up their
>>machine to auto-log-in to the xdm without
>>a password - that gives you all the functionality people have
>>obviously been clamouring for in 30 years of unix
>>so that it can be exactly like Windows 95.



Re: xdm halt & reboot buttons

2016-07-04 Thread Alexander Hall
 

On July 4, 2016 5:51:06 PM GMT+02:00, Bob Beck  wrote:
>>
>> Thinking of it again, you could possibly just use the action
>arguments for
>> a more generic "execute-program" action.
>>
>
>Ahhh.. are you insane? The way you get a generic "execute program"
>action is to LOG IN TO THE DAMN MACHINE!

Heh, I think I need to clarify myself, in that what I'm talking about is 
probably not obvious unless you actually read the code (if even then).

The "generic" action would be how to internally solve adding the required 
functionality and bind it to a key or two. It would not be configurable by the 
user, but could be used by an admin to add any pre-authentication he or she 
wishes, be it halt -p, zzz or *shrug* uptime. 

That said, maybe this is handing out more than a reasonable amount of rope and 
ammo for hurting the system. 

/Alexander 

>
>Why don't you guys just make an option so someone can set up their
>machine to auto-log-in to the xdm without
>a password - that gives you all the functionality people have
>obviously been clamouring for in 30 years of unix
>so that it can be exactly like Windows 95.



Re: xdm halt & reboot buttons

2016-07-04 Thread Bob Beck
I mean, in all seriousness, what you want to do is probably more
safely accomplished by having a way for the "owner"
of the machine to configure it to just log them in without a password,
and then pop a program like xlock that locks their
screen and presents the hibernate suspend and other such bullshit buttons.

It would be safer than you guys trying to screw around and do this as
root and dropping to someone-but-not-the-logged-in-user

I'd never use it.. I think you're nuts. but at least then you aren't
trying to make a security sensitive program that has one
job (log the damn user in) become a swiss-army-clusterfuck


On Mon, Jul 4, 2016 at 9:51 AM, Bob Beck  wrote:
>>
>> Thinking of it again, you could possibly just use the action arguments for
>> a more generic "execute-program" action.
>>
>
> Ahhh.. are you insane? The way you get a generic "execute program"
> action is to LOG IN TO THE DAMN MACHINE!
>
> Why don't you guys just make an option so someone can set up their
> machine to auto-log-in to the xdm without
> a password - that gives you all the functionality people have
> obviously been clamouring for in 30 years of unix
> so that it can be exactly like Windows 95.



Re: xdm halt & reboot buttons

2016-07-04 Thread Theo de Raadt
> On Mon, Jul 4, 2016 at 6:42 AM, Craig Skinner  wrote:
> > On 2016-07-02 Sat 11:21 AM |, Bob Beck wrote:
> >> On Saturday, 2 July 2016, Craig Skinner  wrote:
> >> >
> >> > xmessage is now run as '_x11', shutdown as 'operator', and the status
> >> > items as 'nobody'. Only user _x11's xmessage windows are pkilled.
> >> >
> >>
> >> Do not use nobody.
> >>
> >> that is a very bad practice.  may as well call nobody NFS.
> >>
> >
> > Thanks Bob;- user 'nobody' nuked & replaced by 'operator'.
> 
> 
> That's probably not better - now a bug in xdm can read your raw
> disks..  You need to rethink this

EXACTLY.

Craig, you are taking a program which should run with less privilege;
but because you want features, you are creating a worst-case scenario
that is very dangerous.



Re: xdm halt & reboot buttons

2016-07-04 Thread Craig Skinner
On 2016-07-02 Sat 11:21 AM |, Bob Beck wrote:
> On Saturday, 2 July 2016, Craig Skinner  wrote:
> >
> > xmessage is now run as '_x11', shutdown as 'operator', and the status
> > items as 'nobody'. Only user _x11's xmessage windows are pkilled.
> >
> 
> Do not use nobody.
> 
> that is a very bad practice.  may as well call nobody NFS.
> 

Thanks Bob;- user 'nobody' nuked & replaced by 'operator'.

Anything else to get sorted?

--- /etc/X11/xdm/Xsetup_0   2016/06/28 14:20:18 1.1
+++ /etc/X11/xdm/Xsetup_0   2016/07/04 13:20:56
@@ -1,8 +1,51 @@
 #!/bin/sh
-# $OpenBSD: Xsetup_0,v 1.1 2016/06/28 13:20:18 craig Exp $
+# $OpenBSD: Xsetup_0,v 1.17 2016/07/04 12:23:59 craig Exp $
+
+# Convenience GUI button items:
+alias su_x11='su -s /bin/sh _x11 -c'
+alias su_optr='su -s /bin/sh operator -c'
+
+function _xdm_machine_shutdown
+{
+   su_x11 "xmessage -geometry +0+0 -buttons 'Shutdown:20,Reboot:21' ' 
Machine:'"
+   case $? in
+   20)
+   su_optr "shutdown -hp now 'xdm login screen'"
+   ;;
+   21)
+   su_optr "shutdown -r now 'xdm login screen'"
+   ;;
+   esac
+}
+
+function _xdm_machine_status
+{
+   while true
+   do
+   su_x11 "xmessage -geometry -0+0 -buttons 'Battery:30,Load:31' ' 
Status:'"
+   case $? in
+   30)
+   su_optr 'apm'
+   ;;
+   31)
+   su_optr 'uptime'
+   ;;
+   # TODO:
+   #32)
+   #   su_optr 'some-wifi-status-thing'
+   #   ;;
+   *)
+   break
+   ;;
+   esac
+   done
+}
+
 if [ "$DISPLAY" = ":0" -o "$DISPLAY" = ":0.0" ]
 then
xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed 
-exitOnFail
+   _xdm_machine_shutdown >/dev/console 2>&1 &
+   _xdm_machine_status >/dev/console 2>&1 &
 fi
 
 #sxpm OpenBSD.xpm &
--- /etc/X11/xdm/GiveConsole2015/06/30 16:44:10 1.2
+++ /etc/X11/xdm/GiveConsole2016/07/02 13:18:32
@@ -1,6 +1,11 @@
 #!/bin/sh
 # Assign ownership of the console to the invoking user
-# $OpenBSD: GiveConsole,v 1.2 2015/06/30 15:44:10 craig Exp $
+# $OpenBSD: GiveConsole,v 1.4 2016/07/02 12:24:40 craig Exp $
+#
+
+# Started in Xsetup_0
+pkill -U _x11 -x xmessage
+
 #
 # By convention, both xconsole and xterm -C check that the
 # console is owned by the invoking user and is readable before attaching



Re: xdm halt & reboot buttons

2016-07-02 Thread Alexander Hall
On Sat, Jul 02, 2016 at 01:02:57AM +0200, Alexander Hall wrote:
> On Fri, Jul 01, 2016 at 03:38:26PM +0200, Matthieu Herrb wrote:
> > On Fri, Jul 01, 2016 at 02:22:57PM +0100, Craig Skinner wrote:
> > > Hi Alexander,
> > > 
> > > On 2016-06-30 Thu 20:58 PM |, Alexander Hall wrote:
> > > > 
> > > > 1. xmessage has an sometimes useful, but in general awful, interface.
> > > 
> > > Aye,... simple, in base & functional.
> > > 
> > > The prettiness factor can be cosmetically altered with Xmessage* lines
> > > in /etc/X11/xdm/Xresources. See '! xmessage resources' mid way down:
> > > http://cafim.sssup.it/~giulio/other/Customization_XDM.html
> > > 
> > > > 
> > > > Maybe just add a button or two to the xdm login panel instead?
> > > > 
> > > 
> > > Good idea. I'll try to alter that instead Suggestions welcome!
> > 
> > I'm not sure it's a good idea. The Login widget in xdm is ugly old
> > code. You will loose hair or your mind trying to hack there, unless
> > you decide to first clean it up completely.
> > 
> > If you spend some time providing a set of nice resouces for xmessages
> > and keep it minimalistic, I think we can include your suggestion. I've
> > been waiting for other comments.
> 
> Just throwing in another nickel here - *if* this was in the login widget
> instead, you'd be able to use the keyboard to reach these. As is it now,
> you, AFAIK, aren't. :-/

This adds 'Ctrl+[SZQ]' bindings for suspend, hibernate and powerdown,
respecively.  This gives you added functionality without modifying the
interface, for better or worse. Mostly hacked up for fun and food-for-thought.

Hibernate is probably pretty silly here (unless you have important
stuff going on in the background).

Thinking of it again, you could possibly just use the action arguments for
a more generic "execute-program" action.

Anyways, here goes.

/Alexander


Index: greeter/Login.c
===
RCS file: /cvs/xenocara/app/xdm/greeter/Login.c,v
retrieving revision 1.6
diff -u -p -r1.6 Login.c
--- greeter/Login.c 15 Mar 2015 17:20:41 -  1.6
+++ greeter/Login.c 3 Jul 2016 01:17:12 -
@@ -1289,6 +1289,75 @@ RestartSession (
 
 /*ARGSUSED*/
 static void
+Exec (Widget ctxw, char *const argv[], const char *failMsg)
+{
+LoginWidget ctx = (LoginWidget)ctxw;
+
+pid_t pid = fork();
+if (pid == -1)
+{
+/* fork() failed. */
+} 
+else if (pid == 0)
+{
+   execv(argv[0], argv);
+/* execv() failed... */
+_exit(99);
+}
+else 
+{
+int status;
+if (waitpid(pid, , 0) == pid &&
+   WIFEXITED(status) &&
+   WEXITSTATUS(status) == 0) {
+   XorCursor (ctx);
+   RemoveFail (ctx);
+   ResetLogin (ctx);
+   XorCursor (ctx);
+   return;
+   }
+}
+ErrorMessage(ctx, failMsg, True);
+}
+
+/*ARGSUSED*/
+static void
+SuspendMachine (
+Widget ctxw,
+XEvent *event,
+String *params,
+Cardinal   *num_params)
+{
+char *argv[] = { "/usr/sbin/zzz", NULL };
+Exec (ctxw, argv, "Suspend failed");
+}
+
+/*ARGSUSED*/
+static void
+HibernateMachine (
+Widget ctxw,
+XEvent *event,
+String *params,
+Cardinal   *num_params)
+{
+char *argv[] = { "/usr/sbin/ZZZ", NULL };
+Exec (ctxw, argv, "Hibernation failed");
+}
+
+/*ARGSUSED*/
+static void
+PowerdownMachine (
+Widget ctxw,
+XEvent *event,
+String *params,
+Cardinal   *num_params)
+{
+char *argv[] = { "/sbin/shutdown", "-p", "now", NULL };
+Exec (ctxw, argv, "Shutdown failed");
+}
+
+/*ARGSUSED*/
+static void
 AbortSession (
 Widget ctxw,
 XEvent *event,
@@ -2027,6 +2096,9 @@ char defaultLoginTranslations [] =
 "CtrlX:   erase-line() \n"
 "CtrlC:   restart-session() \n"
 "Ctrl:abort-session() \n"
+"CtrlS:   suspend-machine() \n"
+"CtrlZ:   hibernate-machine() \n"
+"CtrlQ:   powerdown-machine() \n"
 ":Ctrlplus:   allow-all-access() \n"
 "BackSpace:   delete-previous-character() \n"
 #ifdef linux
@@ -2054,6 +2126,9 @@ XtActionsRec loginActionsTable [] = {
   {"abort-session",AbortSession},
   {"abort-display",AbortDisplay},
   {"restart-session",  RestartSession},
+  {"suspend-machine",  SuspendMachine},
+  {"hibernate-machine",HibernateMachine},
+  {"powerdown-machine",PowerdownMachine},
   {"insert-char",  InsertChar},
   {"set-session-argument", SetSessionArgument},
   {"allow-all-access", AllowAccess},



Re: xdm halt & reboot buttons

2016-07-02 Thread Bob Beck
Do not use nobody.

that is a very bad practice.  may as well call nobody NFS.

On Saturday, 2 July 2016, Craig Skinner  wrote:

> Hello all,
>
> On 2016-07-01 Fri 18:01 PM |, Sebastien Marie wrote:
> >
> > It is the fact that xmessage would be run as root that worry me a bit.
> > [snip]
> >
> > Now, as xmessage(1) would be only used to provide UI to user, it should
> > be possible to run it as _x11 (or other unpriviligied user). The useful
> > information is the exit code of the program, so the rest of the script
> > (the "case...esac" stuff) could be run as root and only read the exit
> > code of an unpriviligied one.
> >
> > About the "pkill" in GiveConsole, I think it should be more "restricted"
> > (with -U, -x ...) : else any running xmessage(1) program on the host
> > will be killed (remote X11 xmessage on the host while another user log
> > using xdm).
>
>
> xmessage is now run as '_x11', shutdown as 'operator', and the status
> items as 'nobody'. Only user _x11's xmessage windows are pkilled.
>
> (Maybe the operator & nobody bits are overkill.)
>
> As Patrick requested, the bits can simply be disabled by easy comments.
>
> Feel free to further improve:
>
>
> --- /etc/X11/xdm/Xsetup_0   2016/06/28 14:20:18 1.1
> +++ /etc/X11/xdm/Xsetup_0   2016/07/02 14:58:30
> @@ -1,8 +1,52 @@
>  #!/bin/sh
> -# $OpenBSD: Xsetup_0,v 1.1 2016/06/28 13:20:18 craig Exp $
> +# $OpenBSD: Xsetup_0,v 1.16 2016/07/02 14:03:14 craig Exp $
> +
> +# Convenience GUI button items:
> +alias su_x11='su -s /bin/sh _x11 -c'
> +alias su_optr='su -s /bin/sh operator -c'
> +alias su_nbdy='su -s /bin/sh nobody -c'
> +
> +function _xdm_machine_shutdown
> +{
> +   su_x11 "xmessage -geometry +0+0 -buttons 'Shutdown:20,Reboot:21' '
> Machine:'"
> +   case $? in
> +   20)
> +   su_optr "shutdown -hp now 'xdm login screen'"
> +   ;;
> +   21)
> +   su_optr "shutdown -r now 'xdm login screen'"
> +   ;;
> +   esac
> +}
> +
> +function _xdm_machine_status
> +{
> +   while true
> +   do
> +   su_x11 "xmessage -geometry -0+0 -buttons
> 'Battery:30,Load:31' ' Status:'"
> +   case $? in
> +   30)
> +   su_nbdy 'apm'
> +   ;;
> +   31)
> +   su_nbdy 'uptime'
> +   ;;
> +   # TODO:
> +   #32)
> +   #   su_nbdy 'some-wifi-status-thing'
> +   #   ;;
> +   *)
> +   break
> +   ;;
> +   esac
> +   done
> +}
> +
>  if [ "$DISPLAY" = ":0" -o "$DISPLAY" = ":0.0" ]
>  then
> xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed
> -exitOnFail
> +   _xdm_machine_shutdown >/dev/console 2>&1 &
> +   _xdm_machine_status >/dev/console 2>&1 &
>  fi
>
>  #sxpm OpenBSD.xpm &
> --- /etc/X11/xdm/GiveConsole2015/06/30 16:44:10 1.2
> +++ /etc/X11/xdm/GiveConsole2016/07/02 13:18:32
> @@ -1,6 +1,11 @@
>  #!/bin/sh
>  # Assign ownership of the console to the invoking user
> -# $OpenBSD: GiveConsole,v 1.2 2015/06/30 15:44:10 craig Exp $
> +# $OpenBSD: GiveConsole,v 1.4 2016/07/02 12:24:40 craig Exp $
> +#
> +
> +# Started in Xsetup_0
> +pkill -U _x11 -x xmessage
> +
>  #
>  # By convention, both xconsole and xterm -C check that the
>  # console is owned by the invoking user and is readable before attaching
>
>


Re: xdm halt & reboot buttons

2016-07-02 Thread Craig Skinner
On 2016-07-01 Fri 15:38 PM |, Matthieu Herrb wrote:
> 
> If you spend some time providing a set of nice resouces for xmessages
> and keep it minimalistic, I think we can include your suggestion. I've
> been waiting for other comments.
>

Thanks Matthieu.

I wasted a while making an arse of /etc/X11/xdm/Xresources,
and some kangaroos are now blindly bouncing into buses.

My monitor is in rehab

Who is good at that GUI stuff?
-- 
"Apathy is not the problem, it's the solution"



Re: xdm halt & reboot buttons

2016-07-02 Thread Craig Skinner
Hello all,

On 2016-07-01 Fri 18:01 PM |, Sebastien Marie wrote:
> 
> It is the fact that xmessage would be run as root that worry me a bit.
> [snip]
> 
> Now, as xmessage(1) would be only used to provide UI to user, it should
> be possible to run it as _x11 (or other unpriviligied user). The useful
> information is the exit code of the program, so the rest of the script
> (the "case...esac" stuff) could be run as root and only read the exit
> code of an unpriviligied one.
> 
> About the "pkill" in GiveConsole, I think it should be more "restricted"
> (with -U, -x ...) : else any running xmessage(1) program on the host
> will be killed (remote X11 xmessage on the host while another user log
> using xdm).


xmessage is now run as '_x11', shutdown as 'operator', and the status
items as 'nobody'. Only user _x11's xmessage windows are pkilled.

(Maybe the operator & nobody bits are overkill.)

As Patrick requested, the bits can simply be disabled by easy comments.

Feel free to further improve:


--- /etc/X11/xdm/Xsetup_0   2016/06/28 14:20:18 1.1
+++ /etc/X11/xdm/Xsetup_0   2016/07/02 14:58:30
@@ -1,8 +1,52 @@
 #!/bin/sh
-# $OpenBSD: Xsetup_0,v 1.1 2016/06/28 13:20:18 craig Exp $
+# $OpenBSD: Xsetup_0,v 1.16 2016/07/02 14:03:14 craig Exp $
+
+# Convenience GUI button items:
+alias su_x11='su -s /bin/sh _x11 -c'
+alias su_optr='su -s /bin/sh operator -c'
+alias su_nbdy='su -s /bin/sh nobody -c'
+
+function _xdm_machine_shutdown
+{
+   su_x11 "xmessage -geometry +0+0 -buttons 'Shutdown:20,Reboot:21' ' 
Machine:'"
+   case $? in
+   20)
+   su_optr "shutdown -hp now 'xdm login screen'"
+   ;;
+   21)
+   su_optr "shutdown -r now 'xdm login screen'"
+   ;;
+   esac
+}
+
+function _xdm_machine_status
+{
+   while true
+   do
+   su_x11 "xmessage -geometry -0+0 -buttons 'Battery:30,Load:31' ' 
Status:'"
+   case $? in
+   30)
+   su_nbdy 'apm'
+   ;;
+   31)
+   su_nbdy 'uptime'
+   ;;
+   # TODO:
+   #32)
+   #   su_nbdy 'some-wifi-status-thing'
+   #   ;;
+   *)
+   break
+   ;;
+   esac
+   done
+}
+
 if [ "$DISPLAY" = ":0" -o "$DISPLAY" = ":0.0" ]
 then
xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed 
-exitOnFail
+   _xdm_machine_shutdown >/dev/console 2>&1 &
+   _xdm_machine_status >/dev/console 2>&1 &
 fi
 
 #sxpm OpenBSD.xpm &
--- /etc/X11/xdm/GiveConsole2015/06/30 16:44:10 1.2
+++ /etc/X11/xdm/GiveConsole2016/07/02 13:18:32
@@ -1,6 +1,11 @@
 #!/bin/sh
 # Assign ownership of the console to the invoking user
-# $OpenBSD: GiveConsole,v 1.2 2015/06/30 15:44:10 craig Exp $
+# $OpenBSD: GiveConsole,v 1.4 2016/07/02 12:24:40 craig Exp $
+#
+
+# Started in Xsetup_0
+pkill -U _x11 -x xmessage
+
 #
 # By convention, both xconsole and xterm -C check that the
 # console is owned by the invoking user and is readable before attaching



Re: xdm halt & reboot buttons

2016-07-01 Thread Alexander Hall
On Fri, Jul 01, 2016 at 03:38:26PM +0200, Matthieu Herrb wrote:
> On Fri, Jul 01, 2016 at 02:22:57PM +0100, Craig Skinner wrote:
> > Hi Alexander,
> > 
> > On 2016-06-30 Thu 20:58 PM |, Alexander Hall wrote:
> > > 
> > > 1. xmessage has an sometimes useful, but in general awful, interface.
> > 
> > Aye,... simple, in base & functional.
> > 
> > The prettiness factor can be cosmetically altered with Xmessage* lines
> > in /etc/X11/xdm/Xresources. See '! xmessage resources' mid way down:
> > http://cafim.sssup.it/~giulio/other/Customization_XDM.html
> > 
> > > 
> > > Maybe just add a button or two to the xdm login panel instead?
> > > 
> > 
> > Good idea. I'll try to alter that instead Suggestions welcome!
> 
> I'm not sure it's a good idea. The Login widget in xdm is ugly old
> code. You will loose hair or your mind trying to hack there, unless
> you decide to first clean it up completely.
> 
> If you spend some time providing a set of nice resouces for xmessages
> and keep it minimalistic, I think we can include your suggestion. I've
> been waiting for other comments.

Just throwing in another nickel here - *if* this was in the login widget
instead, you'd be able to use the keyboard to reach these. As is it now,
you, AFAIK, aren't. :-/

/Alexander

> -- 
> Matthieu Herrb




Re: xdm halt & reboot buttons

2016-07-01 Thread Craig Skinner
Hi Patrick,

On 2016-07-01 Fri 10:38 AM |, patrick keshishian wrote:
> 
> Only comment I (as a user) have, has to do with liking the
> default look as-is.

Same for me. It's not pretty, but it's in keeping with the rest of the
landscape. Some CSS type guru could refashion the whole thing.

> I like the idea of this being put in a separate script/program
> (suggested by Alexander Hall); that way, it can easily be disabled
> (reverted to original look) with a one-line comment.
> 

Most of the ideas on the web are TCL or Perl windows, which means
/usr/local/, which means ports, and they were so complicated,
writing PID files, watcher processes to kill the scripts, ugh...

The page I adapted as a starting point was so simple & in base.

I hear you about easy on/off, + Alexander with an external widget.
-- 
Craig Skinner | http://linkd.in/yGqkv7



Re: xdm halt & reboot buttons

2016-07-01 Thread Craig Skinner
On 2016-07-01 Fri 18:01 PM |, Sebastien Marie wrote:
> 
> It is the fact that xmessage would be run as root that worry me a bit.

Good point Sebastien.

> Now, as xmessage(1) would be only used to provide UI to user, it should
> be possible to run it as _x11 (or other unpriviligied user). The useful
> information is the exit code of the program, so the rest of the script
> (the "case...esac" stuff) could be run as root and only read the exit
> code of an unpriviligied one.
> 

OK, I'll investigate that next.

My 4th version uses shutdown(8), which can run as operator.
I guess nobody could run apm(8) too.

> About the "pkill" in GiveConsole, I think it should be more "restricted"
> (with -U, -x ...) : else any running xmessage(1) program on the host
> will be killed (remote X11 xmessage on the host while another user log
> using xdm).

Yeah, I've a space at the front of the message, so pgrep -l was getting
a bit weird. But running xmessage as _x11 changes the situation!

Cheers,
-- 
Craig Skinner | http://linkd.in/yGqkv7



Re: xdm halt & reboot buttons

2016-07-01 Thread Craig Skinner
On 2016-07-01 Fri 14:22 PM |, Craig Skinner wrote:
> On 2016-06-30 Thu 20:58 PM |, Alexander Hall wrote:
> > 
> > Maybe just add a button or two to the xdm login panel instead?
> > 
> 
> Good idea. I'll try to alter that instead Suggestions welcome!
> 

Ugh,... that's beyond me.

>From xdm(1), the AUTHENTICATION WIDGET is special purpose, with
xlogin.Login.namePrompt and xlogin.Login.passwdPrompt, but not
xlogin.Login.MyNewButton1, xlogin.Login.MyNewButton2,

Sorry Alexander.


Anyway, here's another attempt, with less buttons.

The 1st xmessage window has no loop to break as shutdown & reboot are
single instance actions. It also uses shutdown(8) to log to
/var/log/authlog, and can be run by operator instead of root.

The 2nd xmessage window on the top right of the screen diverts battery
state info to the console below it. This needs a breakable loop to be
run more than once.


--- /etc/X11/xdm/Xsetup_0   2016/06/28 14:20:18 1.1
+++ /etc/X11/xdm/Xsetup_0   2016/07/01 20:30:24
@@ -1,8 +1,38 @@
 #!/bin/sh
-# $OpenBSD: Xsetup_0,v 1.1 2016/06/28 13:20:18 craig Exp $
+# $OpenBSD: Xsetup_0,v 1.13 2016/07/01 19:51:18 craig Exp $
 if [ "$DISPLAY" = ":0" -o "$DISPLAY" = ":0.0" ]
 then
xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed 
-exitOnFail
+
+   # Convenience GUI buttons via a backgrounded sub shell:
+   (
+   xmessage -buttons 'Shutdown:20,Reboot:21' ' Machine:'
+   case $? in
+   20)
+   shutdown -hp now 'xdm login screen'
+   ;;
+   21)
+   shutdown -r now 'xdm login screen'
+   ;;
+   esac
+   ) >/dev/console 2>&1 &
+
+   # Convenience GUI buttons via a backgrounded sub shell:
+   (
+   while true
+   do
+   xmessage -geometry -0+0 -buttons 'Status:24' ' Battery:'
+   case $? in
+   24)
+   apm
+   ;;
+   *)
+   break
+   ;;
+   esac
+   done
+   ) >/dev/console 2>&1 &
+
 fi
 
 #sxpm OpenBSD.xpm &
--- /etc/X11/xdm/GiveConsole2015/06/30 16:44:10 1.2
+++ /etc/X11/xdm/GiveConsole2016/06/28 17:07:28
@@ -1,6 +1,11 @@
 #!/bin/sh
 # Assign ownership of the console to the invoking user
-# $OpenBSD: GiveConsole,v 1.2 2015/06/30 15:44:10 craig Exp $
+# $OpenBSD: GiveConsole,v 1.3 2016/06/28 16:09:24 craig Exp $
+#
+
+# Started in Xsetup_0
+pkill xmessage
+
 #
 # By convention, both xconsole and xterm -C check that the
 # console is owned by the invoking user and is readable before attaching



Re: xdm halt & reboot buttons

2016-07-01 Thread patrick keshishian
On 7/1/16, Matthieu Herrb  wrote:
> On Fri, Jul 01, 2016 at 02:22:57PM +0100, Craig Skinner wrote:
>> Hi Alexander,
>>
>> On 2016-06-30 Thu 20:58 PM |, Alexander Hall wrote:
>> >
>> > 1. xmessage has an sometimes useful, but in general awful, interface.
>>
>> Aye,... simple, in base & functional.
>>
>> The prettiness factor can be cosmetically altered with Xmessage* lines
>> in /etc/X11/xdm/Xresources. See '! xmessage resources' mid way down:
>> http://cafim.sssup.it/~giulio/other/Customization_XDM.html
>>
>> >
>> > Maybe just add a button or two to the xdm login panel instead?
>> >
>>
>> Good idea. I'll try to alter that instead Suggestions welcome!
>
> I'm not sure it's a good idea. The Login widget in xdm is ugly old
> code. You will loose hair or your mind trying to hack there, unless
> you decide to first clean it up completely.
>
> If you spend some time providing a set of nice resouces for xmessages
> and keep it minimalistic, I think we can include your suggestion. I've
> been waiting for other comments.


Only comment I (as a user) have, has to do with liking the
default look as-is. I like the idea of this being put in a
separate script/program (suggested by Alexander Hall); that
way, it can easily be disabled (reverted to original look)
with a one-line comment.

cheers,
--patrick



Re: xdm halt & reboot buttons

2016-07-01 Thread Sebastien Marie
On Fri, Jul 01, 2016 at 03:38:26PM +0200, Matthieu Herrb wrote:
> 
> If you spend some time providing a set of nice resouces for xmessages
> and keep it minimalistic, I think we can include your suggestion. I've
> been waiting for other comments.

Personally I would be a bit reluctant to xmessage stuff (at least "as
it"), but it could be only due to my ignorance in the deep of X11
protocol.

It is the fact that xmessage would be run as root that worry me a bit.
My first react (with first version where xmessage wasn't killed in
GiveConsole) was "how is it possible to low-level interact with this X11
app" (I didn't take the time to check it for now).

For comparing, the other program, xconsole(1), which is started by
Xsetup_0, has privsep.

Now, as xmessage(1) would be only used to provide UI to user, it should
be possible to run it as _x11 (or other unpriviligied user). The useful
information is the exit code of the program, so the rest of the script
(the "case...esac" stuff) could be run as root and only read the exit
code of an unpriviligied one.

About the "pkill" in GiveConsole, I think it should be more "restricted"
(with -U, -x ...) : else any running xmessage(1) program on the host
will be killed (remote X11 xmessage on the host while another user log
using xdm).
-- 
Sebastien Marie



Re: xdm halt & reboot buttons

2016-07-01 Thread Matthieu Herrb
On Fri, Jul 01, 2016 at 02:22:57PM +0100, Craig Skinner wrote:
> Hi Alexander,
> 
> On 2016-06-30 Thu 20:58 PM |, Alexander Hall wrote:
> > 
> > 1. xmessage has an sometimes useful, but in general awful, interface.
> 
> Aye,... simple, in base & functional.
> 
> The prettiness factor can be cosmetically altered with Xmessage* lines
> in /etc/X11/xdm/Xresources. See '! xmessage resources' mid way down:
> http://cafim.sssup.it/~giulio/other/Customization_XDM.html
> 
> > 
> > Maybe just add a button or two to the xdm login panel instead?
> > 
> 
> Good idea. I'll try to alter that instead Suggestions welcome!

I'm not sure it's a good idea. The Login widget in xdm is ugly old
code. You will loose hair or your mind trying to hack there, unless
you decide to first clean it up completely.

If you spend some time providing a set of nice resouces for xmessages
and keep it minimalistic, I think we can include your suggestion. I've
been waiting for other comments.
-- 
Matthieu Herrb


pgptk0ge9G4R3.pgp
Description: PGP signature


Re: xdm halt & reboot buttons

2016-07-01 Thread Craig Skinner
Hi Alexander,

On 2016-06-30 Thu 20:58 PM |, Alexander Hall wrote:
> 
> 1. xmessage has an sometimes useful, but in general awful, interface.

Aye,... simple, in base & functional.

The prettiness factor can be cosmetically altered with Xmessage* lines
in /etc/X11/xdm/Xresources. See '! xmessage resources' mid way down:
http://cafim.sssup.it/~giulio/other/Customization_XDM.html

> 
> Maybe just add a button or two to the xdm login panel instead?
> 

Good idea. I'll try to alter that instead Suggestions welcome!

Cheers,
-- 
Craig Skinner | http://linkd.in/yGqkv7



Re: xdm halt & reboot buttons

2016-06-30 Thread Alexander Hall
On Thu, Jun 30, 2016 at 04:43:12PM +0100, Craig Skinner wrote:
> Hiya,
> 
> On 2016-06-29 Wed 14:46 PM |, Craig Skinner wrote:
> > On 2016-06-28 Tue 15:27 PM |, Craig Skinner wrote:
> > > This diff presents 'Halt' and 'Reboot' buttons on the xdm screen.
> > > 
> > 
> > Now it closes the message box + adds 'Hibernate' & 'Suspend' buttons.
> > 
> > > 
> > > Adapted from http://cafim.sssup.it/~giulio/other/Customization_XDM.html
> > > 
> > 
> 
> Send all the sub shell's output to the console, + battery & load stats:

1. xmessage has an sometimes useful, but in general awful, interface.
2. Too much code in 'XSetup*'. It should be a separate program.
3. I don't approve of the diagnostic parts (uptime, really?).

Maybe just add a button or two to the xdm login panel instead?

/Alexander

> 
> 
> --- /etc/X11/xdm/Xsetup_0 2016/06/28 14:20:18 1.1
> +++ /etc/X11/xdm/Xsetup_0 2016/06/30 16:16:09
> @@ -1,8 +1,40 @@
>  #!/bin/sh
> -# $OpenBSD: Xsetup_0,v 1.1 2016/06/28 13:20:18 craig Exp $
> +# $OpenBSD: Xsetup_0,v 1.12 2016/06/30 15:19:52 craig Exp $
>  if [ "$DISPLAY" = ":0" -o "$DISPLAY" = ":0.0" ]
>  then
>   xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed 
> -exitOnFail
> +
> + # Convenience GUI buttons via a backgrounded sub shell:
> + (
> + while true
> + do
> + xmessage -buttons 
> 'Halt:20,Reboot:21,Suspend:22,Hibernate:23,Battery?:24,Load?:25' ' System: '
> + case $? in
> + 20)
> + halt -p && break
> + ;;
> + 21)
> + reboot && break
> + ;;
> + 22)
> + zzz
> + ;;
> + 23)
> + ZZZ
> + ;;
> + 24)
> + apm
> + ;;
> + 25)
> + uptime
> + ;;
> + *)
> + break
> + ;;
> + esac
> + done
> + ) >/dev/console 2>&1 &
> +
>  fi
>  
>  #sxpm OpenBSD.xpm &
> --- /etc/X11/xdm/GiveConsole  2015/06/30 16:44:10 1.2
> +++ /etc/X11/xdm/GiveConsole  2016/06/28 17:07:28
> @@ -1,6 +1,11 @@
>  #!/bin/sh
>  # Assign ownership of the console to the invoking user
> -# $OpenBSD: GiveConsole,v 1.2 2015/06/30 15:44:10 craig Exp $
> +# $OpenBSD: GiveConsole,v 1.3 2016/06/28 16:09:24 craig Exp $
> +#
> +
> +# Started in Xsetup_0
> +pkill xmessage
> +
>  #
>  # By convention, both xconsole and xterm -C check that the
>  # console is owned by the invoking user and is readable before attaching
> 



Re: xdm halt & reboot buttons

2016-06-30 Thread Craig Skinner
Hiya,

On 2016-06-29 Wed 14:46 PM |, Craig Skinner wrote:
> On 2016-06-28 Tue 15:27 PM |, Craig Skinner wrote:
> > This diff presents 'Halt' and 'Reboot' buttons on the xdm screen.
> > 
> 
> Now it closes the message box + adds 'Hibernate' & 'Suspend' buttons.
> 
> > 
> > Adapted from http://cafim.sssup.it/~giulio/other/Customization_XDM.html
> > 
> 

Send all the sub shell's output to the console, + battery & load stats:


--- /etc/X11/xdm/Xsetup_0   2016/06/28 14:20:18 1.1
+++ /etc/X11/xdm/Xsetup_0   2016/06/30 16:16:09
@@ -1,8 +1,40 @@
 #!/bin/sh
-# $OpenBSD: Xsetup_0,v 1.1 2016/06/28 13:20:18 craig Exp $
+# $OpenBSD: Xsetup_0,v 1.12 2016/06/30 15:19:52 craig Exp $
 if [ "$DISPLAY" = ":0" -o "$DISPLAY" = ":0.0" ]
 then
xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed 
-exitOnFail
+
+   # Convenience GUI buttons via a backgrounded sub shell:
+   (
+   while true
+   do
+   xmessage -buttons 
'Halt:20,Reboot:21,Suspend:22,Hibernate:23,Battery?:24,Load?:25' ' System: '
+   case $? in
+   20)
+   halt -p && break
+   ;;
+   21)
+   reboot && break
+   ;;
+   22)
+   zzz
+   ;;
+   23)
+   ZZZ
+   ;;
+   24)
+   apm
+   ;;
+   25)
+   uptime
+   ;;
+   *)
+   break
+   ;;
+   esac
+   done
+   ) >/dev/console 2>&1 &
+
 fi
 
 #sxpm OpenBSD.xpm &
--- /etc/X11/xdm/GiveConsole2015/06/30 16:44:10 1.2
+++ /etc/X11/xdm/GiveConsole2016/06/28 17:07:28
@@ -1,6 +1,11 @@
 #!/bin/sh
 # Assign ownership of the console to the invoking user
-# $OpenBSD: GiveConsole,v 1.2 2015/06/30 15:44:10 craig Exp $
+# $OpenBSD: GiveConsole,v 1.3 2016/06/28 16:09:24 craig Exp $
+#
+
+# Started in Xsetup_0
+pkill xmessage
+
 #
 # By convention, both xconsole and xterm -C check that the
 # console is owned by the invoking user and is readable before attaching



Re: xdm halt & reboot buttons

2016-06-29 Thread Craig Skinner
Hello,

On 2016-06-28 Tue 15:27 PM |, Craig Skinner wrote:
> This diff presents 'Halt' and 'Reboot' buttons on the xdm screen.
> 

Now it closes the message box + adds 'Hibernate' & 'Suspend' buttons.

> 
> Adapted from http://cafim.sssup.it/~giulio/other/Customization_XDM.html
> 


--- /etc/X11/xdm/Xsetup_0   2016/06/28 14:20:18 1.1
+++ /etc/X11/xdm/Xsetup_0   2016/06/28 17:14:54
@@ -1,8 +1,31 @@
 #!/bin/sh
-# $OpenBSD: Xsetup_0,v 1.1 2016/06/28 13:20:18 craig Exp $
+# $OpenBSD: Xsetup_0,v 1.6 2016/06/28 16:16:11 craig Exp $
 if [ "$DISPLAY" = ":0" -o "$DISPLAY" = ":0.0" ]
 then
xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed 
-exitOnFail
+
+   # Show Halt and Reboot buttons:
+   (
+   xmessage -buttons 'Halt:20,Reboot:21,Suspend:22,Hibernate:23' ' 
System: '
+   case $? in
+   20)
+   halt -p >/dev/console 2>&1
+   ;;
+   21)
+   reboot >/dev/console 2>&1
+   ;;
+   22)
+   zzz >/dev/console 2>&1
+   ;;
+   23)
+   ZZZ >/dev/console 2>&1
+   ;;
+   *)
+   print 'xdm halter closed' >/dev/console
+   ;;
+   esac
+   ) &
+
 fi
 
 #sxpm OpenBSD.xpm &
--- /etc/X11/xdm/GiveConsole2015/06/30 16:44:10 1.2
+++ /etc/X11/xdm/GiveConsole2016/06/28 17:07:28
@@ -1,6 +1,11 @@
 #!/bin/sh
 # Assign ownership of the console to the invoking user
-# $OpenBSD: GiveConsole,v 1.2 2015/06/30 15:44:10 craig Exp $
+# $OpenBSD: GiveConsole,v 1.3 2016/06/28 16:09:24 craig Exp $
+#
+
+# Started in Xsetup_0
+pkill xmessage
+
 #
 # By convention, both xconsole and xterm -C check that the
 # console is owned by the invoking user and is readable before attaching



xdm halt & reboot buttons

2016-06-28 Thread Craig Skinner
Hello,

This diff presents 'Halt' and 'Reboot' buttons on the xdm screen.

Other buttons could be added, such as 'Hibernate' & 'Suspend'.

The message box remains after login but can be manually closed.

Adapted from 
http://cafim.sssup.it/~giulio/other/Customization_XDM.html#starting-the-necessary-programs


--- Xsetup_0~   Wed Aug  6 21:03:43 2014
+++ Xsetup_0Tue Jun 28 13:51:23 2016
@@ -1,8 +1,25 @@
 #!/bin/sh
-# $OpenBSD: Xsetup_0,v 1.3 2010/03/28 09:33:02 matthieu Exp $
+# $OpenBSD: Xsetup_0,v 1.2 2016/06/28 13:24:23 craig Exp $
 if [ "$DISPLAY" = ":0" -o "$DISPLAY" = ":0.0" ]
 then
xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed 
-exitOnFail
+
+   # Show Halt and Reboot buttons:
+   (
+   xmessage -buttons 'Halt:20,Reboot:21' ' System: '
+   case $? in
+   20)
+   exec halt -p
+   ;;
+   21)
+   exec reboot
+   ;;
+   *)
+   print "xmessage closed on $(date)"
+   ;;
+   esac
+   ) &
+
 fi
 
 #sxpm OpenBSD.xpm &