sync code with last improvements from OpenBSD

This commit is contained in:
purplerain 2023-08-28 05:57:34 +00:00
commit 88965415ff
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
26235 changed files with 29195616 additions and 0 deletions

321
app/ssh-askpass/ChangeLog Normal file
View file

@ -0,0 +1,321 @@
2001-02-14 04:10 jmknoble
* Imakefile: New version 1.2.0.
2001-02-14 04:07 jmknoble
* README, x11-ssh-askpass.c, x11-ssh-askpass.h,
x11-ssh-askpass.man.in: Updated copyright notices to include 2001.
2001-02-14 04:06 jmknoble
* Imakefile, README: Moved default BINDIR to
/usr/local/libexec/openssh to conform with recent releases of
portable OpenSSH.
2001-02-14 03:59 jmknoble
* x11-ssh-askpass.c, x11-ssh-askpass.h, x11-ssh-askpass.man.in: Now
x11-ssh-askpass understands newline characters ('\n') in text
labels (both the prompt string and the button labels). Each line
of text in the label is displayed on a separate line in the dialog.
Requested by Markus Friedl
<markus.friedl@informatik.uni-erlangen.de> to support
challenge/response authentication in OpenSSH.
2001-02-14 03:49 jmknoble
* x11-ssh-askpass.c: Bugfix: "*grabServer" resource was setting
flag to grab pointer. Fixed. (Not surprising that no one noticed;
i suspect it's not very widely used).
2001-02-14 03:46 jmknoble
* x11-ssh-askpass.man.in: Merged changes from matthieu@openbsd.org:
Use .Nm instead of @NAME@. It fixes a strange formatting error.
2000-11-08 23:19 jmknoble
* Imakefile: New version 1.1.1.
2000-11-08 23:19 jmknoble
* x11-ssh-askpass.c: Fixed problem where inputTimeout of '0' was
considered invalid due to bad octal conversion. Fixed small
potential memory leak.
2000-11-07 06:20 jmknoble
* Imakefile: Bumped version to 1.1.0.
2000-11-07 06:20 jmknoble
* TODO: Added notes about recently done stuff (that's what todo
lists are for, isn't it?;).
2000-11-07 06:16 jmknoble
* SshAskpass-1337.ad, SshAskpass-NeXTish.ad, SshAskpass-default.ad,
SshAskpass-green.ad, SshAskpass-motif.ad: Added new '*inputTimeout'
resource, with explanatory comment.
2000-11-07 06:15 jmknoble
* x11-ssh-askpass.man.in: Documented new '*inputTimeout' resource.
2000-11-07 06:15 jmknoble
* x11-ssh-askpass.c: Fixed a few warnings, commented another.
Print message to stderr when we time out, so as not to completely
confuse the user.
2000-11-07 05:42 jmknoble
* x11-ssh-askpass.c, x11-ssh-askpass.h: Did stuff to handle timing
out if no input received. In particular, this required changing
XNextEvent() in main application loop to XtAppNextEvent(). May
make this larger and more cumbersome....
Also did stuff to make the button labels shift down and to the
right when pressed if they're drawn with 3D shading/highlighting,
so that they actually *look* pressed.
Finally, added code to handle MotionNotify events, so that buttons
don't continue to look pressed if the pointer button is pressed,
but the pointer is outside the button. Wheeeee! Now we have an
actual user interface!
2000-11-07 05:23 jmknoble
* SshAskpass-1337.ad, SshAskpass-NeXTish.ad, SshAskpass-default.ad,
SshAskpass-green.ad, SshAskpass-motif.ad: Converted colors from
old-style "#rrggbb" to new-style "rgb:rr/gg/bb". Corrected typo in
perspicacious commentary.
2000-10-30 05:28 jmknoble
* Imakefile: Bumped version to 1.0.3.
2000-10-30 05:28 jmknoble
* SshAskpass-1337.ad, SshAskpass-NeXTish.ad, SshAskpass-default.ad,
SshAskpass-green.ad, SshAskpass-motif.ad: Added resources used for
pseudo-resolution-independence, along with default values and long,
drawn out, but mildly fulfilling explanation.
2000-10-30 05:27 jmknoble
* x11-ssh-askpass.man.in: Documented the new resources for
pseudo-resolution-independence (defaultXResolution,
defaultYResolution, xResolutionFuzz, and yResolutionFuzz).
2000-10-30 05:25 jmknoble
* x11-ssh-askpass.c, x11-ssh-askpass.h: Added a small amount of
resolution-independence to the dialog widgets. Now we detect the
actual X and Y resolution the server is running at; and if they're
significantly different from the ones our resource settings expect,
then we stretch or shrink buttons, indicators, and spacing to fit
the actual resolution. Sometimes X11 really makes my stomach
hurt....
2000-09-24 00:51 jmknoble
* Imakefile: New version 1.0.2.
2000-09-24 00:43 jmknoble
* x11-ssh-askpass.c, x11-ssh-askpass.h: Added process ID to
diagnostic/error messages on stderr (helps when more than one
ssh-askpass is started, e.g., with a shortcut key and keyboard
repeat).
Modified keyboard and pointer grabbing so that, if we don't get the
keyboard or pointer the first time, we print a helpful message,
sleep, and then retry. If we time out without successfully getting
the keyboard or pointer, then we fail as before.
Combined the logic for grabKeyboard() and grabPointer() into a
common function performGrab(). This makes it easier to ensure that
the grab/sleep logic is correct in both places.
Fixed, worked around or commented on a few warnings emitted by 'gcc
-Wall -W -ansi -pedantic'.
2000-09-24 00:32 jmknoble
* resources.c: Removed unused declaration of get_time_resource.
2000-08-28 03:35 jmknoble
* Imakefile, TODO: Added TODO file for listing potential future
projects within x11-ssh-askpass.
2000-08-28 03:35 jmknoble
* README: Added 'make install.man' to installation instructions.
Formulated better wording for reference to (now ancient) Perl/Tk
ssh-askpass.
2000-08-28 03:26 jmknoble
* Imakefile, x11-ssh-askpass.man.in: Added facilities to Imakefile
and man page to automatically insert name, date, and version into
man page. Changed install target to include man page. Rearranged
clean and dist targets slightly. Ready for release.
2000-08-28 02:54 jmknoble
* x11-ssh-askpass.man.in: Added corrections and clarifications:
Mentioned optional label on command line; noted which toolkit
options are unsupported; and added extra indicator-specific
resources.
2000-08-28 02:00 jmknoble
* x11-ssh-askpass.c: Moved saving of argc/argv to after call to
XtAppInitialize(), so that toolkit arguments get properly removed
from the argument list.
2000-08-28 01:43 jmknoble
* x11-ssh-askpass.man.in: Changed author email address from
pobox.com to jmknoble.cx. Added 2000 to copyright date.
2000-08-28 01:42 jmknoble
* x11-ssh-askpass.man.in: Added man page for x11-ssh-askpass from
Matthieu Herrb <matthieu@laas.fr> of OpenBSD.
2000-08-28 01:31 jmknoble
* README, SshAskpass-1337.ad, SshAskpass-NeXTish.ad,
SshAskpass-default.ad, SshAskpass-green.ad, SshAskpass-motif.ad,
dynlist.c, dynlist.h, x11-ssh-askpass.c, x11-ssh-askpass.h: Changed
ISO-8859-1 copyright character '©' to ASCII '(C)'.
2000-08-28 01:27 jmknoble
* README, SshAskpass-1337.ad, SshAskpass-NeXTish.ad,
SshAskpass-default.ad, SshAskpass-green.ad, SshAskpass-motif.ad,
drawing.c, drawing.h, dynlist.c, dynlist.h, resources.c,
resources.h, x11-ssh-askpass.c, x11-ssh-askpass.h: Changed author
email address from pobox.com to jmknoble.cx. Added 2000 to
copyright date.
2000-08-28 01:19 jmknoble
* x11-ssh-askpass.c: Oops. When the keyboard or pointer grab
failed, the fprintf() calls to print the error message were missing
the 'reason' argument. Thanks to Daniel Packman
<pack@mop2.eos.ucar.edu>.
2000-08-28 01:17 jmknoble
* Imakefile: Portability enhancements to Imakefile, suggested by
Charles Levert <charles@comm.polymtl.ca>. Use imake's '...Cmd'
macros where available; otherwise, use less-nonportable commands.
Bumped version to 1.0.1.
2000-01-07 04:53 jmknoble
* README: Added note about location of x11-ssh-askpass.
2000-01-07 04:52 jmknoble
* Imakefile: Now we install the actual program as
`x11-ssh-askpass', and make a symlink to that from `ssh-askpass'.
This allows for multiple passphrase dialogs on a system.
Bumped version to 1.0.
1999-12-24 01:59 jmknoble
* Imakefile: Oops. Version backed out to 0.99; missing spec file
for building RPMs.
1999-12-24 01:05 jmknoble
* Imakefile: Updated version to 1.0. Removed reference to utils.h.
Prefer install targets available in X11R6.
1999-12-24 01:00 jmknoble
* README: Updated install directory. Removed reference to utils.h.
1999-12-24 00:58 jmknoble
* resources.c, resources.h: Moved header includes from utils.h into
resources.c. Trimmed unused functions.
1999-12-24 00:56 jmknoble
* dynlist.c: Removed potential memory leak (and ensuing loss of
buffer contents) if realloc() failed.
1999-12-24 00:53 jmknoble
* utils.h: Moved header includes from here into resources.c.
1999-12-04 23:21 jmknoble
* Imakefile: Added patch from Markus Friedl to change use of awk
(with GNU-specific extensions?) to sed, more likely to be available
on various platforms.
1999-11-23 05:16 jmknoble
* .cvsignore: Added ChangeLog to .cvsignore.
1999-11-23 05:14 jmknoble
* Imakefile: Added facility for autogenerating ChangeLog using
cvs2cl.
1999-11-23 04:57 jmknoble
* .cvsignore, README, README.x11-ssh-askpass:
README.x11-ssh-askpass moved to README. Shorter.
1999-11-23 04:55 jmknoble
* .cvsignore: Added .cvsignore file.
1999-11-23 04:53 jmknoble
* Imakefile, SshAskpass-1337.ad, SshAskpass-NeXTish.ad,
SshAskpass-default.ad, SshAskpass-green.ad, SshAskpass-motif.ad,
x11-ssh-askpass.c, x11-ssh-askpass.h: - Added version to tarball.
- *grab(Keyboard|Pointer|Server) resources had inverted values in
app-defaults files. - Futzed with spacing in default and NeXTish
themes. - Added setrlimit() call to main() to avoid core dumps.
1999-11-23 04:50 jmknoble
* Imakefile, SshAskpass-1337.ad, SshAskpass-NeXTish.ad,
SshAskpass-default.ad, SshAskpass-green.ad, SshAskpass-motif.ad,
resources.c, resources.h, x11-ssh-askpass.c, x11-ssh-askpass.h: -
Can optionally grab server (*grabServer resource, off by default).
- get_pixel_resource(), get_integer_resource() now take default
value. - Added minimum/maximum indicator count. - memset()
passphrase to 0s before freeing. - Use fputs() instead of printf()
to avoid possibility of passphrase getting stored in dynamic
memory by stdio.
1999-11-23 04:43 jmknoble
* Imakefile, README.x11-ssh-askpass, SshAskpass-1337.ad,
SshAskpass-NeXTish.ad, SshAskpass-default.ad, SshAskpass-green.ad,
SshAskpass-motif.ad, drawing.c, drawing.h, dynlist.c, dynlist.h,
resources.c, resources.h, utils.h, x11-ssh-askpass.c,
x11-ssh-askpass.h: Initial revision
1999-11-23 04:43 jmknoble
* Imakefile, README.x11-ssh-askpass, SshAskpass-1337.ad,
SshAskpass-NeXTish.ad, SshAskpass-default.ad, SshAskpass-green.ad,
SshAskpass-motif.ad, drawing.c, drawing.h, dynlist.c, dynlist.h,
resources.c, resources.h, utils.h, x11-ssh-askpass.c,
x11-ssh-askpass.h: Begin CVS revision control

37
app/ssh-askpass/Imakefile Normal file
View file

@ -0,0 +1,37 @@
XCOMM $OpenBSD: Imakefile,v 1.2 2007/01/09 21:49:12 matthieu Exp $
SRCS = drawing.c dynlist.c resources.c x11-ssh-askpass.c
OBJS = drawing.o dynlist.o resources.o x11-ssh-askpass.o
DEPLIBS = $(DEPXTOOLLIB) $(DEPXLIB) $(DEPXINERAMALIB)
LOCAL_LIBRARIES = $(XTOOLLIB) $(XLIB) $(XINERAMALIB)
NAME = ssh-askpass
CLASS = SshAskpass
VERSION = 1.2.0
DATE = February 14, 2001
APP_DEFAULTS = $(CLASS)-default.ad
$(CLASS)_ad.h: $(CLASS).ad
cat $(CLASS).ad | grep -v '^[ ]*$$' |\
awk '/^[ ]*!/ { sub("^[ ]*![ ]?","", $$0); printf("/* %s */\n", $$0); next } ! /^[ ]*!/ { printf("\"%s\",\n", $$0) }' \
>$@
$(CLASS).ad:
$(LN) $(APP_DEFAULTS) $(CLASS).ad
$(NAME).man: x11-ssh-askpass.man.in Imakefile
sed \@@\
-e 's#@NAME@#$(NAME)#g' \@@\
-e 's#@VERSION@#$(VERSION)#g' \@@\
-e 's#@DATE@#$(DATE)#g' \@@\
<x11-ssh-askpass.man.in >$@.tmp
$(MV) $@.tmp $@
includes:: $(CLASS)_ad.h $(NAME).man
clean::
$(RM) -f $(CLASS)_ad.h $(CLASS).ad
$(RM) -f $(NAME).man
ComplexProgramTarget($(NAME))
InstallAppDefaults($(CLASS))

43
app/ssh-askpass/Makefile Normal file
View file

@ -0,0 +1,43 @@
# $OpenBSD: Makefile,v 1.14 2014/08/13 21:02:16 matthieu Exp $
.include <bsd.xconf.mk>
PROG= ssh-askpass
SRCS= drawing.c dynlist.c resources.c x11-ssh-askpass.c
MANDIR= ${X11BASE}/man/man
CLASS= SshAskpass
VERSION= 1.2.0
DATE= February 14, 2001
APP_DEFAULTS= $(CLASS)-default.ad
CPPFLAGS+= -I${X11BASE}/include -I.
LDADD+= -L${X11BASE}/lib -lXt -lSM -lICE -lXinerama -lX11 -lxcb -lXau -lXdmcp -lXext
CLEANFILES+= ${CLASS}.ad ${CLASS}_ad.h ssh-askpass.1
ssh-askpass.1: x11-ssh-askpass.man.in
sed -e 's#@NAME@#$(PROG)#g' -e 's#@VERSION@#$(VERSION)#g' \
-e 's#@DATE@#$(DATE)#g' < $(.CURDIR)/x11-ssh-askpass.man.in > $@
$(CLASS)_ad.h: $(CLASS).ad
grep -v '^[ ]*$$' $(CLASS).ad |\
awk '/^[ ]*!/ { sub("^[ ]*![ ]?","", $$0); printf("/* %s */\n", $$0); next } ! /^[ ]*!/ { printf("\"%s\",\n", $$0) }' \
>$@
$(CLASS).ad: $(APP_DEFAULTS)
rm -f $(CLASS).ad
ln -s $(.CURDIR)/$(APP_DEFAULTS) $(CLASS).ad
# XXX why isn't $(CLASS)_ad.h being build before .depend?
x11-ssh-askpass.o: $(CLASS)_ad.h
afterinstall:
${INSTALL_DATA} $(CLASS).ad \
$(DESTDIR)${X11BASE}/share/X11/app-defaults/$(CLASS)
beforedepend: $(CLASS)_ad.h
obj: _xenocara_obj
.include <bsd.prog.mk>
.include <bsd.xorg.mk>

153
app/ssh-askpass/README Normal file
View file

@ -0,0 +1,153 @@
# README: Notes about X11-based passphrase dialog for OpenSSH
# created 1999-Nov-21 jmk
# autodate: 2001-Feb-14 04:07
+-------------+
| Description |
+-------------+
This is an X11-based passphrase dialog for use with OpenSSH. It is
intended to replace the Perl/Tk-based ssh-askpass dialog and
GNOME-based ssh-askpass dialog which formerly accompanied OpenSSH-1.2.
These dialogs are intended to be called from the ssh-add program and
not invoked directly.
The features of x11-ssh-askpass are as follows:
- Configurable via the standard X resource mechanism
(/usr/lib/X11/app-defaults, ~/.Xdefaults, xrdb, etc.).
- Require only stock X11 libraries (libXt, libX11, libSM, libICE).
- Can be configured to grab the keyboard and/or pointer (grabs the
keyboard by default, not the pointer).
The user interface is somewhat different than most password/passphrase
dialogs and more similar to the X11-based passphrase dialog that
accompanies the regular SSH distribution. Instead of a text field that
fills with asterisks or some other character as the user enters the
passphrase, a series of LED-like areas light up one-by-one with each
passphrase character entered, beginning from the lefthand edge of the
dialog. When they reach the righthand edge, they go dark one-by-one
again, and so on. This gives the user feedback that passphrase
characters have been entered, but does not provide onlookers with a cue
as to the length of the passphrase.
Pressing the `OK' button accepts the passphrase (even if it is empty),
which is printed on the standard output, and the dialog exits with a
status of zero (success). Pressing the `Cancel' button discards the
passphrase, and the dialog exits with non-zero status.
The following keystrokes work as expected:
[Backspace] or [Delete] Erase previous character
[Control+U] or [Control+X] Erase entire passphrase
[Enter], [Control+M], or [Control+J] Accept passphrase (OK)
[Escape] Discard passphrase (Cancel)
+------------+
| Installing |
+------------+
x11-ssh-askpass currently uses imake and xmkmf to build. Here's the
procedure:
xmkmf
make includes
make
make install
make install.man
x11-ssh-askpass installs by default in /usr/local/libexec/openssh/. To
install it somewhere else (for example, /usr/libexec/openssh/) use:
make install BINDIR=/usr/libexec/openssh
Several different app-defaults files accompany x11-ssh-askpass:
SshAskpass-1337.ad - small, dark, and gray
SshAskpass-NeXTish.ad - a look mildly similar to that of NEXTstep
SshAskpass-default.ad - the default look
SshAskpass-green.ad - somewhat green
SshAskpass-motif.ad - a bit like the look of the Motif toolkit
If you wish a look other than the default, perform the following
commands before building (for example):
rm -f SshAskpass_ad.h
make includes APP_DEFAULTS=SshAskpass-NeXTish.ad
+-----------------+
| Where To Get It |
+-----------------+
x11-ssh-askpass is available at:
http://www.jmknoble.cx/software/x11-ssh-askpass/
+--------------------------+
| Copyright, License, Etc. |
+--------------------------+
Some portions of x11-ssh-askpass are derived directly or indirectly
from portions of xscreensaver by Jamie Zawinski <jwz@jwz.org>, while
others are original works.
The contents of the following files is taken directly, in whole or in
part, from xscreensaver:
drawing.c
drawing.h
resources.c
resources.h
The contents of the following files contains a limited amount of code
(less than approximately 25%) which is derived from portions of
xscreensaver:
x11-ssh-askpass.c
The remainder of the code is an original work, including the following
files:
dynlist.c
dynlist.h
x11-ssh-askpass.h
*.ad
The portions derived from xscreensaver require the following notice:
xscreensaver, Copyright (c) 1991-1999 Jamie Zawinski <jwz@jwz.org>
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear in
supporting documentation. No representations are made about the
suitability of this software for any purpose. It is provided "as is"
without express or implied warranty.
The remaining portions fall under the following copyright and license:
by Jim Knoble <jmknoble@jmknoble.cx>
Copyright (C) 1999,2000,2001 Jim Knoble
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear in
supporting documentation.
+------------+
| Disclaimer |
+------------+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
express or implied, including but not limited to the warranties of
merchantability, fitness for a particular purpose and
noninfringement. In no event shall the author(s) be liable for any
claim, damages or other liability, whether in an action of contract,
tort or otherwise, arising from, out of or in connection with the
software or the use or other dealings in the software.
-------- End of file --------

View file

@ -0,0 +1,102 @@
! SshAskpass.ad: Default resources for the X11-based ssh-askpass for OpenSSH
! created 1999-Nov-17 03:40 Jim Knoble <jmknoble@jmknoble.cx>
! autodate: 2000-Nov-07 05:50
!
! by Jim Knoble <jmknoble@jmknoble.cx>
! Copyright (C) 1999,2000 Jim Knoble
!
! Disclaimer:
!
! The software is provided "as is", without warranty of any kind,
! express or implied, including but not limited to the warranties of
! merchantability, fitness for a particular purpose and
! noninfringement. In no event shall the author(s) be liable for any
! claim, damages or other liability, whether in an action of
! contract, tort or otherwise, arising from, out of or in connection
! with the software or the use or other dealings in the software.
!
! Permission to use, copy, modify, distribute, and sell this software
! and its documentation for any purpose is hereby granted without
! fee, provided that the above copyright notice appear in all copies
! and that both that copyright notice and this permission notice
! appear in supporting documentation.
!
! +-------------+
! | e133t theme |
! +-------------+
*Dialog.font: -b&h-lucida-medium-r-normal-*-*-100-*-*-*-*-iso8859-1
*?.foreground: rgb:d0/d0/d0
*?.background: rgb:50/50/50
*topShadowColor: rgb:90/90/90
*bottomShadowColor: rgb:00/00/00
*borderColor: rgb:a0/a0/a0
*shadowThickness: 2
*borderWidth: 1
*horizontalSpacing: 5
*verticalSpacing: 5
*Button.font: -b&h-lucida-medium-r-normal-*-*-100-*-*-*-*-iso8859-1
*Button.shadowThickness: 1
*Button.borderWidth: 0
*Button.horizontalSpacing: 4
*Button.verticalSpacing: 2
*Indicator.foreground: rgb:70/80/90
*Indicator.background: rgb:50/50/50
*Indicator.shadowThickness: 1
*Indicator.borderWidth: 0
*Indicator.height: 4
*Indicator.width: 13
*Indicator.horizontalSpacing: 4
*Indicator.verticalSpacing: 5
*Indicator.minimumCount: 8
*Indicator.maximumCount: 24
! X11 does a miserable job of providing resolution-independent drawing
! facilities---it expects everything to be done in pixels. So if you
! happen to run your X server at a resolution of 100 pixels per inch
! (or some other strange value) instead of the widely used default of
! 75, x11-ssh-askpass looks might tiny. [Sigh].
!
! To get around this, umm, limitation, we declare the resolution that
! the spacing and width/height pixels values are "valid" for, along
! with a fuzz factor. If the current actual resolution is outside of
! the range of <DEFAULT - FUZZ>..<DEFAULT + FUZZ>, then we scale pixel
! measurements to fit the actual resolution.
!
! (And if you think *this* is a horrid hack, then take a look at the
! actual code, which has to deal with conversion to [cheesy fanfare]
! that's right---millimeters!!! The right hand managed to slip that
! one in while the left hand was adding a '-dpi' switch to the sample
! server implementation. I think both left feet were adding the
! RESOLUTION_X and RESOLUTION_Y fields [in dots per inch, naturally]
! to the X Logical Font Description. The irony is underwhelming.)
*defaultXResolution: 75/in
*defaultYResolution: 75/in
*xResolutionFuzz: 20/in
*yResolutionFuzz: 20/in
! Number of seconds to wait for a key- or button-press
! before giving up. '0' means wait forever.
*inputTimeout: 0
! Ssh-askpass grabs the keyboard by default.
! To stop it from grabbing the keyboard, use:
!*grabKeyboard: false
! Ssh-askpass does not grab the pointer by default.
! To make it grab the pointer, use:
!*grabPointer: true
! Ssh-askpass does not grab the server by default.
! To make it grab the server, use:
!*grabServer: true
*Dialog.title: OpenSSH Authentication Passphrase Request
*Dialog.label: Please enter your authentication passphrase:
*okButton.label: OK
*cancelButton.label: Cancel

View file

@ -0,0 +1,104 @@
! SshAskpass.ad: Default resources for the X11-based ssh-askpass for OpenSSH
! created 1999-Nov-17 03:40 Jim Knoble <jmknoble@jmknoble.cx>
! autodate: 2000-Nov-07 05:50
!
! by Jim Knoble <jmknoble@jmknoble.cx>
! Copyright (C) 1999,2000 Jim Knoble
!
! Disclaimer:
!
! The software is provided "as is", without warranty of any kind,
! express or implied, including but not limited to the warranties of
! merchantability, fitness for a particular purpose and
! noninfringement. In no event shall the author(s) be liable for any
! claim, damages or other liability, whether in an action of
! contract, tort or otherwise, arising from, out of or in connection
! with the software or the use or other dealings in the software.
!
! Permission to use, copy, modify, distribute, and sell this software
! and its documentation for any purpose is hereby granted without
! fee, provided that the above copyright notice appear in all copies
! and that both that copyright notice and this permission notice
! appear in supporting documentation.
!
! +--------------------+
! | NEXTstep-ish theme |
! +--------------------+
*Dialog.font: -adobe-helvetica-medium-r-normal-*-*-120-*-*-*-*-iso8859-1
*?.foreground: rgb:00/00/00
*?.background: rgb:a8/a8/a8
*topShadowColor: rgb:ff/ff/ff
*bottomShadowColor: rgb:54/54/54
*borderColor: rgb:20/20/20
*shadowThickness: 0
*borderWidth: 1
*horizontalSpacing: 8
*verticalSpacing: 8
*Button.font: -adobe-helvetica-medium-r-normal-*-*-120-*-*-*-*-iso8859-1
*Button.shadowThickness: 1
*Button.borderWidth: 1
*Button.horizontalSpacing: 8
*Button.verticalSpacing: 3
*Indicator.foreground: rgb:9b/cd/9b
*Indicator.background: rgb:54/54/54
*Indicator.topShadowColor: rgb:ff/ff/ff
*Indicator.bottomShadowColor: rgb:20/20/20
*Indicator.shadowThickness: 1
*Indicator.borderWidth: 0
*Indicator.height: 7
*Indicator.width: 15
*Indicator.horizontalSpacing: 4
*Indicator.verticalSpacing: 6
*Indicator.minimumCount: 8
*Indicator.maximumCount: 24
! X11 does a miserable job of providing resolution-independent drawing
! facilities---it expects everything to be done in pixels. So if you
! happen to run your X server at a resolution of 100 pixels per inch
! (or some other strange value) instead of the widely used default of
! 75, x11-ssh-askpass looks might tiny. [Sigh].
!
! To get around this, umm, limitation, we declare the resolution that
! the spacing and width/height pixels values are "valid" for, along
! with a fuzz factor. If the current actual resolution is outside of
! the range of <DEFAULT - FUZZ>..<DEFAULT + FUZZ>, then we scale pixel
! measurements to fit the actual resolution.
!
! (And if you think *this* is a horrid hack, then take a look at the
! actual code, which has to deal with conversion to [cheesy fanfare]
! that's right---millimeters!!! The right hand managed to slip that
! one in while the left hand was adding a '-dpi' switch to the sample
! server implementation. I think both left feet were adding the
! RESOLUTION_X and RESOLUTION_Y fields [in dots per inch, naturally]
! to the X Logical Font Description. The irony is underwhelming.)
*defaultXResolution: 75/in
*defaultYResolution: 75/in
*xResolutionFuzz: 20/in
*yResolutionFuzz: 20/in
! Number of seconds to wait for a key- or button-press
! before giving up. '0' means wait forever.
*inputTimeout: 0
! Ssh-askpass grabs the keyboard by default.
! To stop it from grabbing the keyboard, use:
!*grabKeyboard: false
! Ssh-askpass does not grab the pointer by default.
! To make it grab the pointer, use:
!*grabPointer: true
! Ssh-askpass does not grab the server by default.
! To make it grab the server, use:
!*grabServer: true
*Dialog.title: OpenSSH Authentication Passphrase Request
*Dialog.label: Please enter your authentication passphrase:
*okButton.label: OK
*cancelButton.label: Cancel

View file

@ -0,0 +1,103 @@
! SshAskpass.ad: Default resources for the X11-based ssh-askpass for OpenSSH
! created 1999-Nov-17 03:40 Jim Knoble <jmknoble@jmknoble.cx>
! autodate: 2000-Nov-07 05:50
!
! by Jim Knoble <jmknoble@jmknoble.cx>
! Copyright (C) 1999,2000 Jim Knoble
!
! Disclaimer:
!
! The software is provided "as is", without warranty of any kind,
! express or implied, including but not limited to the warranties of
! merchantability, fitness for a particular purpose and
! noninfringement. In no event shall the author(s) be liable for any
! claim, damages or other liability, whether in an action of
! contract, tort or otherwise, arising from, out of or in connection
! with the software or the use or other dealings in the software.
!
! Permission to use, copy, modify, distribute, and sell this software
! and its documentation for any purpose is hereby granted without
! fee, provided that the above copyright notice appear in all copies
! and that both that copyright notice and this permission notice
! appear in supporting documentation.
!
! +-----------------------------+
! | Default theme (like SSH v1) |
! +-----------------------------+
*Dialog.font: -adobe-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-1
*Dialog.fixedFont: -adobe-courier-bold-r-normal-*-*-120-*-*-*-*-iso8859-1
*?.foreground: rgb:00/00/00
*?.background: rgb:cc/cc/cc
*topShadowColor: rgb:ff/ff/ff
*bottomShadowColor: rgb:7f/7f/7f
*borderColor: rgb:20/20/20
*shadowThickness: 3
*borderWidth: 1
*horizontalSpacing: 5
*verticalSpacing: 6
*Button.font: -adobe-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-1
*Button.shadowThickness: 2
*Button.borderWidth: 1
*Button.horizontalSpacing: 5
*Button.verticalSpacing: 2
*Indicator.foreground: rgb:9b/cd/9b
*Indicator.background: rgb:00/00/80
*Indicator.shadowThickness: 2
*Indicator.borderWidth: 0
*Indicator.height: 7
*Indicator.width: 15
*Indicator.horizontalSpacing: 2
*Indicator.verticalSpacing: 4
*Indicator.minimumCount: 8
*Indicator.maximumCount: 24
! X11 does a miserable job of providing resolution-independent drawing
! facilities---it expects everything to be done in pixels. So if you
! happen to run your X server at a resolution of 100 pixels per inch
! (or some other strange value) instead of the widely used default of
! 75, x11-ssh-askpass looks might tiny. [Sigh].
!
! To get around this, umm, limitation, we declare the resolution that
! the spacing and width/height pixels values are "valid" for, along
! with a fuzz factor. If the current actual resolution is outside of
! the range of <DEFAULT - FUZZ>..<DEFAULT + FUZZ>, then we scale pixel
! measurements to fit the actual resolution.
!
! (And if you think *this* is a horrid hack, then take a look at the
! actual code, which has to deal with conversion to [cheesy fanfare]
! that's right---millimeters!!! The right hand managed to slip that
! one in while the left hand was adding a '-dpi' switch to the sample
! server implementation. I think both left feet were adding the
! RESOLUTION_X and RESOLUTION_Y fields [in dots per inch, naturally]
! to the X Logical Font Description. The irony is underwhelming.)
*defaultXResolution: 75/in
*defaultYResolution: 75/in
*xResolutionFuzz: 20/in
*yResolutionFuzz: 20/in
! Number of seconds to wait for a key- or button-press
! before giving up. '0' means wait forever.
*inputTimeout: 0
! Ssh-askpass grabs the keyboard by default.
! To stop it from grabbing the keyboard, use:
!*grabKeyboard: false
! Ssh-askpass does not grab the pointer by default.
! To make it grab the pointer, use:
!*grabPointer: true
! Ssh-askpass does not grab the server by default.
! To make it grab the server, use:
!*grabServer: true
*Dialog.title: OpenSSH Authentication Passphrase Request
*Dialog.label: Please enter your authentication passphrase:
*okButton.label: OK
*cancelButton.label: Cancel

View file

@ -0,0 +1,102 @@
! SshAskpass.ad: Default resources for the X11-based ssh-askpass for OpenSSH
! created 1999-Nov-17 03:40 Jim Knoble <jmknoble@jmknoble.cx>
! autodate: 2000-Nov-07 05:50
!
! by Jim Knoble <jmknoble@jmknoble.cx>
! Copyright (C) 1999,2000 Jim Knoble
!
! Disclaimer:
!
! The software is provided "as is", without warranty of any kind,
! express or implied, including but not limited to the warranties of
! merchantability, fitness for a particular purpose and
! noninfringement. In no event shall the author(s) be liable for any
! claim, damages or other liability, whether in an action of
! contract, tort or otherwise, arising from, out of or in connection
! with the software or the use or other dealings in the software.
!
! Permission to use, copy, modify, distribute, and sell this software
! and its documentation for any purpose is hereby granted without
! fee, provided that the above copyright notice appear in all copies
! and that both that copyright notice and this permission notice
! appear in supporting documentation.
!
! +-------------+
! | Green theme |
! +-------------+
*Dialog.font: -adobe-new century schoolbook-bold-r-normal-*-*-140-*-*-*-*-iso8859-1
*?.foreground: rgb:54/ff/9f
*?.background: rgb:2e/8b/57
*topShadowColor: rgb:43/cd/80
*bottomShadowColor: rgb:43/cd/80
*borderColor: rgb:43/cd/80
*shadowThickness: 2
*borderWidth: 0
*horizontalSpacing: 5
*verticalSpacing: 6
*Button.font: -adobe-new century schoolbook-bold-r-normal-*-*-140-*-*-*-*-iso8859-1
*Button.shadowThickness: 0
*Button.borderWidth: 2
*Button.horizontalSpacing: 4
*Button.verticalSpacing: 2
*Indicator.foreground: rgb:ad/ff/2f
*Indicator.background: rgb:2e/8b/57
*Indicator.shadowThickness: 0
*Indicator.borderWidth: 2
*Indicator.height: 7
*Indicator.width: 15
*Indicator.horizontalSpacing: 3
*Indicator.verticalSpacing: 4
*Indicator.minimumCount: 8
*Indicator.maximumCount: 24
! X11 does a miserable job of providing resolution-independent drawing
! facilities---it expects everything to be done in pixels. So if you
! happen to run your X server at a resolution of 100 pixels per inch
! (or some other strange value) instead of the widely used default of
! 75, x11-ssh-askpass looks might tiny. [Sigh].
!
! To get around this, umm, limitation, we declare the resolution that
! the spacing and width/height pixels values are "valid" for, along
! with a fuzz factor. If the current actual resolution is outside of
! the range of <DEFAULT - FUZZ>..<DEFAULT + FUZZ>, then we scale pixel
! measurements to fit the actual resolution.
!
! (And if you think *this* is a horrid hack, then take a look at the
! actual code, which has to deal with conversion to [cheesy fanfare]
! that's right---millimeters!!! The right hand managed to slip that
! one in while the left hand was adding a '-dpi' switch to the sample
! server implementation. I think both left feet were adding the
! RESOLUTION_X and RESOLUTION_Y fields [in dots per inch, naturally]
! to the X Logical Font Description. The irony is underwhelming.)
*defaultXResolution: 75/in
*defaultYResolution: 75/in
*xResolutionFuzz: 20/in
*yResolutionFuzz: 20/in
! Number of seconds to wait for a key- or button-press
! before giving up. '0' means wait forever.
*inputTimeout: 0
! Ssh-askpass grabs the keyboard by default.
! To stop it from grabbing the keyboard, use:
!*grabKeyboard: false
! Ssh-askpass does not grab the pointer by default.
! To make it grab the pointer, use:
!*grabPointer: true
! Ssh-askpass does not grab the server by default.
! To make it grab the server, use:
!*grabServer: true
*Dialog.title: OpenSSH Authentication Passphrase Request
*Dialog.label: Please enter your authentication passphrase:
*okButton.label: OK
*cancelButton.label: Cancel

View file

@ -0,0 +1,102 @@
! SshAskpass.ad: Default resources for the X11-based ssh-askpass for OpenSSH
! created 1999-Nov-17 03:40 Jim Knoble <jmknoble@jmknoble.cx>
! autodate: 2000-Nov-07 05:50
!
! by Jim Knoble <jmknoble@jmknoble.cx>
! Copyright (C) 1999,2000 Jim Knoble
!
! Disclaimer:
!
! The software is provided "as is", without warranty of any kind,
! express or implied, including but not limited to the warranties of
! merchantability, fitness for a particular purpose and
! noninfringement. In no event shall the author(s) be liable for any
! claim, damages or other liability, whether in an action of
! contract, tort or otherwise, arising from, out of or in connection
! with the software or the use or other dealings in the software.
!
! Permission to use, copy, modify, distribute, and sell this software
! and its documentation for any purpose is hereby granted without
! fee, provided that the above copyright notice appear in all copies
! and that both that copyright notice and this permission notice
! appear in supporting documentation.
!
! +-----------------+
! | Motif-ish theme |
! +-----------------+
*Dialog.font: -adobe-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-1
*?.foreground: rgb:00/00/00
*?.background: rgb:c0/c0/c0
*topShadowColor: rgb:e5/e5/e5
*bottomShadowColor: rgb:69/69/69
*borderColor: rgb:00/00/00
*shadowThickness: 2
*borderWidth: 0
*horizontalSpacing: 8
*verticalSpacing: 6
*Button.font: -adobe-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-1
*Button.shadowThickness: 2
*Button.borderWidth: 0
*Button.horizontalSpacing: 5
*Button.verticalSpacing: 4
*Indicator.foreground: rgb:ff/ff/70
*Indicator.background: rgb:4f/94/cd
*Indicator.shadowThickness: 2
*Indicator.borderWidth: 0
*Indicator.height: 7
*Indicator.width: 15
*Indicator.horizontalSpacing: 3
*Indicator.verticalSpacing: 6
*Indicator.minimumCount: 8
*Indicator.maximumCount: 24
! X11 does a miserable job of providing resolution-independent drawing
! facilities---it expects everything to be done in pixels. So if you
! happen to run your X server at a resolution of 100 pixels per inch
! (or some other strange value) instead of the widely used default of
! 75, x11-ssh-askpass looks might tiny. [Sigh].
!
! To get around this, umm, limitation, we declare the resolution that
! the spacing and width/height pixels values are "valid" for, along
! with a fuzz factor. If the current actual resolution is outside of
! the range of <DEFAULT - FUZZ>..<DEFAULT + FUZZ>, then we scale pixel
! measurements to fit the actual resolution.
!
! (And if you think *this* is a horrid hack, then take a look at the
! actual code, which has to deal with conversion to [cheesy fanfare]
! that's right---millimeters!!! The right hand managed to slip that
! one in while the left hand was adding a '-dpi' switch to the sample
! server implementation. I think both left feet were adding the
! RESOLUTION_X and RESOLUTION_Y fields [in dots per inch, naturally]
! to the X Logical Font Description. The irony is underwhelming.)
*defaultXResolution: 75/in
*defaultYResolution: 75/in
*xResolutionFuzz: 20/in
*yResolutionFuzz: 20/in
! Number of seconds to wait for a key- or button-press
! before giving up. '0' means wait forever.
*inputTimeout: 0
! Ssh-askpass grabs the keyboard by default.
! To stop it from grabbing the keyboard, use:
!*grabKeyboard: false
! Ssh-askpass does not grab the pointer by default.
! To make it grab the pointer, use:
!*grabPointer: true
! Ssh-askpass does not grab the server by default.
! To make it grab the server, use:
!*grabServer: true
*Dialog.title: OpenSSH Authentication Passphrase Request
*Dialog.label: Please enter your authentication passphrase:
*okButton.label: OK
*cancelButton.label: Cancel

27
app/ssh-askpass/TODO Normal file
View file

@ -0,0 +1,27 @@
# TODO: Notes about future work on x11-ssh-askpass
# created 2000-Aug-28 03:32 jmk
# autodate: 2000-Nov-07 06:19
+------------+
| Fun Things |
+------------+
- (DONE) Add timeout feature.
+---------------+
| High Priority |
+---------------+
No items.
+--------------+
| Low Priority |
+--------------+
- (DONE) Make pressed buttons actually look pressed.
- (DONE) Make pressed buttons pop back up when the pointer leaves them.
- Investigate use of malloc() vs realloc(NULL,) for SunOS and other
older systems. Charles Levert <charles@comm.polymtl.ca>

81
app/ssh-askpass/drawing.c Normal file
View file

@ -0,0 +1,81 @@
/* xscreensaver, Copyright (c) 1991-1998 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*/
/* 1999-Nov-21 Modified by Jim Knoble <jmknoble@jmknoble.cx>
* Modifications:
* - Extracted draw_shaded_rectangle() from xscreensaver source for use
* in a separate application. Constructed separate header file.
*/
#include <X11/Intrinsic.h>
void
draw_shaded_rectangle (Display *dpy, Window window,
int x, int y,
int width, int height,
int thickness,
unsigned long top_color,
unsigned long bottom_color)
{
XPoint points[4];
XGCValues gcv;
GC gc1, gc2;
if (thickness == 0) return;
gcv.foreground = top_color;
gc1 = XCreateGC (dpy, window, GCForeground, &gcv);
gcv.foreground = bottom_color;
gc2 = XCreateGC (dpy, window, GCForeground, &gcv);
points [0].x = x;
points [0].y = y;
points [1].x = x + width;
points [1].y = y;
points [2].x = x + width - thickness;
points [2].y = y + thickness;
points [3].x = x;
points [3].y = y + thickness;
XFillPolygon (dpy, window, gc1, points, 4, Convex, CoordModeOrigin);
points [0].x = x;
points [0].y = y + thickness;
points [1].x = x;
points [1].y = y + height;
points [2].x = x + thickness;
points [2].y = y + height - thickness;
points [3].x = x + thickness;
points [3].y = y + thickness;
XFillPolygon (dpy, window, gc1, points, 4, Convex, CoordModeOrigin);
points [0].x = x + width;
points [0].y = y;
points [1].x = x + width - thickness;
points [1].y = y + thickness;
points [2].x = x + width - thickness;
points [2].y = y + height - thickness;
points [3].x = x + width;
points [3].y = y + height - thickness;
XFillPolygon (dpy, window, gc2, points, 4, Convex, CoordModeOrigin);
points [0].x = x;
points [0].y = y + height;
points [1].x = x + width;
points [1].y = y + height;
points [2].x = x + width;
points [2].y = y + height - thickness;
points [3].x = x + thickness;
points [3].y = y + height - thickness;
XFillPolygon (dpy, window, gc2, points, 4, Convex, CoordModeOrigin);
XFreeGC (dpy, gc1);
XFreeGC (dpy, gc2);
}

31
app/ssh-askpass/drawing.h Normal file
View file

@ -0,0 +1,31 @@
/* xscreensaver, Copyright (c) 1991-1998 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*/
/* 1999-Nov-21 Modified by Jim Knoble <jmknoble@jmknoble.cx>
* Modifications:
* - Extracted draw_shaded_rectangle() from xscreensaver source for use
* in a separate application. Constructed separate header file.
*/
#ifndef _DRAWING_H_
#define _DRAWING_H_
#include <X11/Intrinsic.h>
void
draw_shaded_rectangle (Display *dpy, Window window,
int x, int y,
int width, int height,
int thickness,
unsigned long top_color,
unsigned long bottom_color);
#endif /* _DRAWING_H_ */

82
app/ssh-askpass/dynlist.c Normal file
View file

@ -0,0 +1,82 @@
/* dynlist.c: Dynamic lists and buffers in C.
* created 1999-Jan-06 15:34 jmk
* autodate: 2000-Aug-28 01:29
*
* by Jim Knoble <jmknoble@jmknoble.cx>
* Copyright (C) 1999,2000 Jim Knoble
*
* Disclaimer:
*
* The software is provided "as is", without warranty of any kind,
* express or implied, including but not limited to the warranties of
* merchantability, fitness for a particular purpose and
* noninfringement. In no event shall the author(s) be liable for any
* claim, damages or other liability, whether in an action of
* contract, tort or otherwise, arising from, out of or in connection
* with the software or the use or other dealings in the software.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation.
*/
#include <stdio.h>
#include <stdlib.h>
#include "dynlist.h"
#define LIST_CHUNK_SIZE 512
#define BUF_CHUNK_SIZE 512
/* For lists of pointers cast to char *. */
int append_to_list(char ***list_ptr, int *list_len, int *i, char *item)
{
char **tmp_ptr;
if (*i >= *list_len)
{
*list_len += LIST_CHUNK_SIZE;
tmp_ptr = realloc(*list_ptr, (sizeof(**list_ptr) * *list_len));
if (NULL == tmp_ptr)
{
free(*list_ptr);
*list_ptr = NULL;
return(APPEND_FAILURE);
} else {
*list_ptr = tmp_ptr;
}
*list_ptr = tmp_ptr;
}
(*list_ptr)[*i] = item;
(*i)++;
return(APPEND_SUCCESS);
}
/* For single-dimensional buffers. */
int append_to_buf(char **buf, int *buflen, int *i, int c)
{
char *tmp_buf;
if (*i >= *buflen)
{
*buflen += BUF_CHUNK_SIZE;
tmp_buf = realloc(*buf, (sizeof(**buf) * *buflen));
if (NULL == tmp_buf)
{
free(*buf);
*buf = NULL;
return(APPEND_FAILURE);
} else {
*buf = tmp_buf;
}
*buf = tmp_buf;
#ifdef DEBUG
printf("-->Allocated buffer of size %d\n", *buflen);
#endif /* DEBUG */
}
(*buf)[*i] = (char) c;
(*i)++;
return(APPEND_SUCCESS);
}

34
app/ssh-askpass/dynlist.h Normal file
View file

@ -0,0 +1,34 @@
/* dynlist.h: Dynamic lists and buffers in C
* created 1999-Jan-06 15:04 jmk
* autodate: 2000-Aug-28 01:29
*
* by Jim Knoble <jmknoble@jmknoble.cx>
* Copyright (C) 1999,2000 Jim Knoble
*
* Disclaimer:
*
* The software is provided "as is", without warranty of any kind,
* express or implied, including but not limited to the warranties of
* merchantability, fitness for a particular purpose and
* noninfringement. In no event shall the author(s) be liable for any
* claim, damages or other liability, whether in an action of
* contract, tort or otherwise, arising from, out of or in connection
* with the software or the use or other dealings in the software.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation.
*/
#ifndef H_DYNLIST
#define H_DYNLIST 1
#define APPEND_SUCCESS 1
#define APPEND_FAILURE 0
int append_to_list(char ***list_ptr, int *list_len, int *i, char *item);
int append_to_buf(char **buf, int *buflen, int *i, int c);
#endif /* H_DYNLIST */

190
app/ssh-askpass/resources.c Normal file
View file

@ -0,0 +1,190 @@
/* xscreensaver, Copyright (c) 1992, 1997, 1998
* Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*/
/* 1999-Nov-21 Modified by Jim Knoble <jmknoble@jmknoble.cx>.
* Modifications:
*
* - Made get_boolean_resource() accept a third parameter, default_value,
* which determines the result of get_boolean_resource if either (a)
* no such resource exists, or (b) the resource value does not conform
* to the syntax of a boolean resource.
*
* - Same for get_integer_resource(), get_pixel_resource().
*
* - 1999-Dec-24 Moved header includes from utils.h to here.
* Trimmed unused functions.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <X11/Xlib.h>
#include <X11/Xos.h>
#include <X11/Xresource.h>
#include "resources.h"
/* Resource functions. Assumes: */
extern char *progname;
extern char *progclass;
extern XrmDatabase db;
#ifndef isupper
# define isupper(c) ((c) >= 'A' && (c) <= 'Z')
#endif
#ifndef _tolower
# define _tolower(c) ((c) - 'A' + 'a')
#endif
char *
get_string_resource (char *res_name, char *res_class)
{
XrmValue value;
char *type;
char full_name [1024], full_class [1024];
int result;
result = snprintf(full_name, sizeof(full_name), "%s.%s",
progname, res_name);
if (result == -1 || result >= sizeof(full_name)) {
fprintf(stderr, "%s: resource name too long: %s.%s\n", progname,
progname, res_name);
return 0;
}
result = snprintf(full_class, sizeof(full_class), "%s.%s",
progclass, res_class);
if (result == -1 || result >= sizeof(full_class)) {
fprintf(stderr, "%s: resource name too long: %s.%s\n", progname,
progclass, res_class);
return 0;
}
if (XrmGetResource (db, full_name, full_class, &type, &value))
{
char *str = (char *) malloc (value.size + 1);
strncpy (str, (char *) value.addr, value.size);
str [value.size] = 0;
return str;
}
return 0;
}
Bool
get_boolean_resource (char *res_name, char *res_class, Bool default_value)
{
char *tmp, buf [100];
char *s = get_string_resource (res_name, res_class);
char *os = s;
if (! s) return default_value;
for (tmp = buf; *s; s++)
*tmp++ = isupper (*s) ? _tolower (*s) : *s;
*tmp = 0;
free (os);
while (*buf &&
(buf[strlen(buf)-1] == ' ' ||
buf[strlen(buf)-1] == '\t'))
buf[strlen(buf)-1] = 0;
if (!strcmp (buf, "on") || !strcmp (buf, "true") || !strcmp (buf, "yes"))
return 1;
if (!strcmp (buf,"off") || !strcmp (buf, "false") || !strcmp (buf,"no"))
return 0;
fprintf (stderr, "%s: %s must be boolean, not %s.\n",
progname, res_name, buf);
return default_value;
}
int
get_integer_resource (char *res_name, char *res_class, int default_value)
{
int val;
char c, *s = get_string_resource (res_name, res_class);
char *ss = s;
if (!s) return default_value;
while (*ss && *ss <= ' ') ss++; /* skip whitespace */
if (ss[0] == '0' && (ss[1] == 'x' || ss[1] == 'X')) /* 0x: parse as hex */
{
if (1 == sscanf (ss+2, "%x %c", &val, &c))
{
free (s);
return val;
}
}
else /* else parse as dec */
{
if (1 == sscanf (ss, "%d %c", &val, &c))
{
free (s);
return val;
}
}
fprintf (stderr, "%s: %s must be an integer, not %s.\n",
progname, res_name, s);
free (s);
return default_value;
}
double
get_float_resource (char *res_name, char *res_class)
{
double val;
char c, *s = get_string_resource (res_name, res_class);
if (! s) return 0.0;
if (1 == sscanf (s, " %lf %c", &val, &c))
{
free (s);
return val;
}
fprintf (stderr, "%s: %s must be a float, not %s.\n",
progname, res_name, s);
free (s);
return 0.0;
}
unsigned int
get_pixel_resource (char *res_name, char *res_class,
Display *dpy, Colormap cmap, unsigned int default_value)
{
XColor color;
char *s = get_string_resource (res_name, res_class);
char *s2;
if (!s) goto DEFAULT;
for (s2 = s + strlen(s) - 1; s2 > s; s2--)
if (*s2 == ' ' || *s2 == '\t')
*s2 = 0;
else
break;
if (! XParseColor (dpy, cmap, s, &color))
{
fprintf (stderr, "%s: can't parse color %s\n", progname, s);
goto DEFAULT;
}
if (! XAllocColor (dpy, cmap, &color))
{
fprintf (stderr, "%s: couldn't allocate color %s\n", progname, s);
goto DEFAULT;
}
free (s);
return color.pixel;
DEFAULT:
if (s) free (s);
return default_value;
}

View file

@ -0,0 +1,34 @@
/* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*/
/* 1999-Nov-21 Modified by Jim Knoble <jmknoble@jmknoble.cx>.
* Modifications:
*
* - Made get_boolean_resource() accept a third parameter, default_value,
* which determines the result of get_boolean_resource if either (a)
* no such resource exists, or (b) the resource value does not conform
* to the syntax of a boolean resource.
*
* - Same for get_integer_resource().
*
* - 1999-Dec-24 Trimmed unused functions.
*/
#ifndef __XSCREENSAVER_RESOURCES_H__
#define __XSCREENSAVER_RESOURCES_H__
extern char *get_string_resource (char*,char*);
extern Bool get_boolean_resource (char*,char*,Bool);
extern int get_integer_resource (char*,char*,int);
extern double get_float_resource (char*,char*);
extern unsigned int get_pixel_resource (char*,char*,Display*,Colormap,unsigned int);
#endif /* __XSCREENSAVER_RESOURCES_H__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,273 @@
/* x11-ssh-askpass.h: A generic X11-based password dialog for OpenSSH.
* created 1999-Nov-17 03:40 Jim Knoble <jmknoble@jmknoble.cx>
* autodate: 2001-Feb-14 04:00
*
* by Jim Knoble <jmknoble@jmknoble.cx>
* Copyright (C) 1999,2000,2001 Jim Knoble
*
* Disclaimer:
*
* The software is provided "as is", without warranty of any kind,
* express or implied, including but not limited to the warranties of
* merchantability, fitness for a particular purpose and
* noninfringement. In no event shall the author(s) be liable for any
* claim, damages or other liability, whether in an action of
* contract, tort or otherwise, arising from, out of or in connection
* with the software or the use or other dealings in the software.
*
* Portions of this code are distantly derived from code in xscreensaver
* by Jamie Zawinski <jwz@jwz.org>. That code says:
*
* --------8<------------------------------------------------8<--------
* xscreensaver, Copyright (c) 1991-1999 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
* --------8<------------------------------------------------8<--------
*
* The remainder of this code falls under the same permissions and
* provisions as those of the xscreensaver code.
*/
#ifndef H_X11_SSH_ASKPASS
#define H_X11_SSH_ASKPASS
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#define EXIT_STATUS_ACCEPT 0
#define EXIT_STATUS_CANCEL 1
#define EXIT_STATUS_NO_MEMORY 2
#define EXIT_STATUS_ERROR 3
#define EXIT_STATUS_TIMEOUT 4
#define EXIT_STATUS_ANOMALY 127
typedef struct
{
Pixel foreground;
Pixel background;
Dimension width;
Dimension height;
Position x;
Position y;
} WidgetInfo;
typedef struct
{
WidgetInfo w;
Pixel topShadowColor;
Pixel bottomShadowColor;
Dimension shadowThickness;
Pixel borderColor;
Dimension borderWidth;
Dimension interiorWidth;
Dimension interiorHeight;
Dimension horizontalSpacing;
Dimension verticalSpacing;
} Widget3dInfo;
typedef struct TextObjectStruct
{
char *text;
int textLength;
int direction;
int ascent;
int descent;
XCharStruct overall;
struct TextObjectStruct *next;
} TextObject;
typedef struct
{
char *fullText;
XFontStruct *font;
XFontStruct *fixedFont;
TextObject *multiText;
WidgetInfo w;
} LabelInfo;
typedef struct
{
Widget3dInfo w3;
LabelInfo label;
Bool pressed;
} ButtonInfo;
typedef struct
{
Widget3dInfo w3;
int count;
int current;
int minimumCount;
int maximumCount;
} MasterIndicatorInfo;
typedef struct
{
MasterIndicatorInfo *parent;
WidgetInfo w;
Bool isLit;
} IndicatorElement;
typedef struct
{
Window dialogWindow;
XSizeHints *sizeHints;
XWMHints *wmHints;
XClassHint *classHints;
XTextProperty windowName;
char *title;
Widget3dInfo w3;
LabelInfo label;
MasterIndicatorInfo indicator;
IndicatorElement *indicators;
ButtonInfo okButton;
ButtonInfo cancelButton;
int pressedButton;
} DialogInfo;
#define NO_BUTTON 0
#define OK_BUTTON 1
#define CANCEL_BUTTON 2
typedef struct
{
char *appName;
char *appClass;
int argc;
char **argv;
pid_t pid;
char *buf;
int bufSize;
int bufIndex;
Display *dpy;
Screen *screen;
long screen_width;
long screen_height;
long screen_xoffset;
long screen_yoffset;
Window rootWindow;
Pixel black;
Pixel white;
Colormap colormap;
/* Resolution measurements are normalized to dots/meter. */
long xResolution;
long yResolution;
long defaultXResolution;
long defaultYResolution;
long xFuzz;
long yFuzz;
XtAppContext appContext;
Widget toplevelShell;
XrmDatabase resourceDb;
Atom wmDeleteWindowAtom;
GC fillGC;
GC borderGC;
GC textGC;
GC brightGC;
GC dimGC;
long eventMask;
Bool grabKeyboard;
Bool grabPointer;
Bool grabServer;
Bool isKeyboardGrabbed;
Bool isPointerGrabbed;
Bool isServerGrabbed;
unsigned int grabFailTimeout;
unsigned int grabRetryInterval;
unsigned long inputTimeout;
XtIntervalId inputTimeoutTimerId;
Bool inputTimeoutActive;
DialogInfo *dialog;
} AppInfo;
void outOfMemory(AppInfo *app, int line);
void freeIf(void *p);
void freeFontIf(AppInfo *app, XFontStruct *f);
XFontStruct *getFontResource(AppInfo *app, char *instanceName, char *className);
char *getStringResourceWithDefault(char *instanceName, char *className,
char *defaultText);
unsigned int getUnsignedIntegerResource(AppInfo *app, char *instanceName,
char *className,
unsigned int defaultValue);
long getResolutionResource(AppInfo *app, char *instanceName, char *className,
char *defaultResolutionSpec);
void calcLabelTextExtents(LabelInfo *label);
void calcTotalButtonExtents(ButtonInfo *button);
void calcButtonExtents(ButtonInfo *button);
void balanceButtonExtents(ButtonInfo *button1, ButtonInfo *button2);
void calcButtonLabelPosition(ButtonInfo *button);
Dimension scaleXDimension(AppInfo *app, Dimension unscaled);
Dimension scaleYDimension(AppInfo *app, Dimension unscaled);
void createDialog(AppInfo *app);
void destroyDialog(AppInfo *app);
void createDialogWindow(AppInfo *app);
void createGCs(AppInfo *app);
void destroyGCs(AppInfo *app);
void paintLabel(AppInfo *app, Drawable draw, LabelInfo label);
void paintButton(AppInfo *app, Drawable draw, ButtonInfo button);
void paintIndicator(AppInfo *app, Drawable draw, IndicatorElement indicator);
void updateIndicatorElement(AppInfo *app, int i);
void updateIndicators(AppInfo *app, int condition);
void paintDialog(AppInfo *app);
#define GRAB_KEYBOARD 0
#define GRAB_POINTER 1
void performGrab(AppInfo *app, int grabType, char *grabTypeName,
Bool shouldGrab, Bool *isGrabbed);
void grabKeyboard(AppInfo *app);
void ungrabKeyboard(AppInfo *app);
void grabPointer(AppInfo *app);
void ungrabPointer(AppInfo *app);
void grabServer(AppInfo *app);
void ungrabServer(AppInfo *app);
void cleanUp(AppInfo *app);
void exitApp(AppInfo *app, int exitCode);
void acceptAction(AppInfo *app);
void cancelAction(AppInfo *app);
void backspacePassphrase(AppInfo *app);
void erasePassphrase(AppInfo *app);
void addToPassphrase(AppInfo *app, char c);
void handleKeyPress(AppInfo *app, XEvent *event);
Bool eventIsInsideButton(AppInfo *app, XEvent *event, ButtonInfo button);
void handleButtonPress(AppInfo *app, XEvent *event);
void handlePointerMotion(AppInfo *app, XEvent *event);
void handleInputTimeout(XtPointer data, XtIntervalId *timerId);
void cancelInputTimeout(AppInfo *app);
#endif /* H_X11_SSH_ASKPASS */

View file

@ -0,0 +1,327 @@
.\" $NetBSD: x11-ssh-askpass.man.in,v 1.2 2011/04/03 13:42:33 wiz Exp $
.\"
.\" x11-ssh-askpass.man
.\" Created by Matthieu Herrb <matthieu@laas.fr> for OpenBSD
.\" Modified by Jim Knoble <jmknoble@jmknoble.cx> for non-OpenBSD
.\" distribution
.\"
.Dd @DATE@
.Dt @NAME@ 1
.Os "Version @VERSION@"
.Sh NAME
.Nm @NAME@
.Nd an X11-based pass-phrase dialog for use with OpenSSH
.Sh SYNOPSIS
.Nm @NAME@
.Op options
.Op label
.Sh DESCRIPTION
.Nm
is an X11-based pass-phrase dialog for use with OpenSSH.
It is intended to be called from the
.Xr ssh-add 1
program and not invoked directly.
.Pp
.Nm
supports most standard Toolkit command line arguments, with the
exception of
.Ar -geometry ,
.Ar -borderwidth ,
.Ar -iconic ,
.Ar -rv ,
and
.Ar -title .
See
.Xr X 7 .
.Pp
If exactly one non-option argument is provided on the command line, it
is displayed in the dialog instead of the default label.
If the argument contains newline characters ('\\n'), each line of text
is displayed on a separate line in the dialog.
.Pp
The features of
.Nm
are as follows:
.Bl -dash -offset indent
.It
Configurable via the standard X resource mechanisms
.Pa /usr/X11R6/share/X11/app-defaults ,
.Pa ~/.Xdefaults ,
.Xr xrdb 1 ,
etc.
.It
Requires only stock X11 libraries (\%libXt, \%libX11, \%libSM, \%libICE).
.It
Can be configured to grab the keyboard and/or pointer (grabs the
keyboard by default, not the pointer).
.El
.Pp
The user interface is somewhat different than most password/pass-phrase
dialogs and more similar to the X11-based pass-phrase dialog that
accompanies the regular SSH distribution.
Instead of a text field that fills with asterisks or some other
character as the user enters the pass-phrase, a series of LED-like
areas light up one-by-one with each pass-phrase character entered,
beginning from the left-hand edge of the dialog.
When they reach the right-hand edge, they go dark one-by-one
again, and so on.
This gives the user feedback that pass-phrase characters have been
entered, but does not provide onlookers with a cue as to the length
of the pass-phrase.
.Pp
Pressing the
.Sq OK
button accepts the pass-phrase (even if it is empty),
which is printed on the standard output, and the dialog exits with a
status of zero (success).
Pressing the
.Sq Cancel
button discards the
pass-phrase, and the dialog exits with non-zero status.
.Pp
The following keystrokes work as expected:
.Pp
.Bl -tag -width "[Backspace]" -offset indent -compact
.It Bq Backspace
.It Bq Delete
Erase previous character
.Pp
.It Bq Control+U
.It Bq Control+X
Erase entire pass-phrase
.Pp
.It Bq Enter
.It Bq Control+M
.It Bq Control+J
Accept pass-phrase (OK)
.Pp
.It Bq Escape
Discard pass-phrase (Cancel)
.El
.Sh WIDGETS
The main window of
.Nm
has the widget hierarchy indicated below.
The widget class name is given first, followed by the instance name.
.Bl -tag -width "Dialog" -offset indent
.It Dialog
dialog
.Pp
.Bl -tag -width "Indicator" -compact
.It Indicator
indicator
.It Button
okButton
.It Button
cancelButton
.El
.El
.Sh RESOURCES
The following resources are used to customize the application
globally:
.Bl -tag -width 2n -offset indent
.It Cm grabKeyboard ( No class Cm GrabKeyboard )
.Bl -inset -compact
.It specifies if the application should grab the keyboard.
.It Default value:
.Dq True .
.El
.It Cm grabPointer ( No class Cm GrabPointer )
.Bl -inset -compact
.It specifies if the application should grab the pointer.
.It Default value:
.Dq False .
.El
.It Cm grabServer ( No class Cm GrabServer )
.Bl -inset -compact
.It specifies if the application should grab the server.
.It Default value:
.Dq False .
.El
.It Cm inputTimeout ( No class Cm InputTimeout )
.Bl -inset -compact
.It the number of seconds
.Nm
should wait for a key or
button press before it gives up and exits.
A timeout of
.Dq 0
means wait forever.
.It Default value:
.Dq 0 .
.El
.It Cm defaultXResolution ( No class Cm DefaultXResolution )
.Bl -inset -compact
.It the number of pixels per unit length that horizontal
spacing and width values are intended for.
If the actual
horizontal (x) resolution of the X server is significantly
greater or less than this value, portions of the dialog,
indicator, and button widgets are stretched or shrunk
horizontally to take the difference into account.
The value is a positive integer, followed by a slash
.Cm ( / )
and a one- or two-character unit abbreviation.
Valid units are inches
.Cm ( in
or
.Cm i )
and meters
.Cm ( m ) .
.It Default value:
.Dq 75/in
(75 pixels per inch).
.El
.It Cm defaultYResolution ( No class Cm DefaultYResolution )
.Bl -inset -compact
.It the number of pixels per unit length that vertical
spacing and height values are intended for.
If the actual
vertical (y) resolution of the X server is significantly
greater or less than this value, portions of the dialog,
indicator, and button widgets are stretched or shrunk
vertically to take the difference into account.
Valid values are the same as for
.Cm defaultXResolution
above.
.It Default value:
.Dq 75/in
(75 pixels per inch).
.El
.It Cm xResolutionFuzz ( No class Cm XResolutionFuzz )
.Bl -inset -compact
.It the range of
.Dq fuzz
around the value of
.Cm defaultXResolution
beyond which some widgets will be stretched or shrunk
horizontally to fit the current actual horizontal
resolution.
Valid values are the same as for
.Cm defaultXResolution .
For example, if the default X resolution is
.Dq 75/in ,
and the X resolution fuzz is
.Dq 50/in ,
then widgets won't be scaled horizontally unless the actual
horizontal resolution is less than 25 pixels per inch or
greater than 125 pixels per inch.
.It Default value:
.Dq 20/in
(20 pixels per inch).
.El
.It Cm yResolutionFuzz ( No class Cm YResolutionFuzz )
.Bl -inset -compact
.It the range of
.Dq fuzz
around the value of
.Cm defaultYResolution
beyond which some widgets will be stretched or shrunk
vertically to fit the current actual vertical
resolution.
Valid values are the same as for
.Cm defaultXResolution
above.
.It Default value:
.Dq 20/in
(20 pixels per inch).
.El
.El
.Pp
The following resources are recognized by the Dialog widget:
.Bl -tag -width 2n -offset indent
.It Cm title ( No class Cm Title )
The title of the application as specified to the window manager.
.It Cm label ( No class Cm Label )
The label displayed above the led indicators.
.It Cm font ( No class Cm Font )
The font to be used to display the first line of label.
.It Cm fixedFont ( No class Cm FixedFont )
The font to be used to display the second and following lines of the label.
.El
.Pp
The following Resources are recognized by the dialog, button, and
indicator widgets and the main widget to customize the 3D appearance
(all measurements are in pixels):
.Bl -tag -width 2n -offset indent
.It Cm foreground ( No class Cm Foreground )
The foreground color of the widget.
This is the text color of the label for buttons and dialog and the
color of the active led for the indicator.
.It Cm background ( No class Cm Background )
The background color of the widget.
In the case of the indicator this is the color of the inactive led.
.It Cm topShadowColor ( No class Cm TopShadowColor )
The color used by the sides of the widget exposed to the light (top
and left).
.It Cm bottomShadowColor ( No class Cm BottomShadowColor )
The color used by the sides of the widget in the shadow (right and
bottom).
.It Cm shadowThickness ( No class Cm ShadowTickness )
The thickness of the 3D border of the widget.
.It Cm borderColor ( No class Cm BorderColor )
The color of the border around the widget.
.It Cm borderWidth ( No class Cm BorderWidth )
The width of the border around the widget.
.It Cm horizontalSpacing ( No class Cm HorizontalSpacing )
The space to leave on left and right sides of the widget.
.It Cm verticalSpacing ( No class Cm VerticalSpacing )
The space to leave on top and bottom sides of the widget.
.El
.Pp
The following resources are recognized by the indicator widgets:
.Bl -tag -width 2n -offset indent
.It Cm minimumCount ( No class Cm MinimumCount )
The minimum number of indicators to display in the dialog.
.It Cm maximumCount ( No class Cm MaximumCount )
The maximum number of indicators to display in the dialog.
.El
.Pp
Each button uses the following resources to customize its label:
.Bl -tag -width 2n -offset indent
.It Cm label ( No class Cm Label )
the string to display on the button.
.It Cm font ( No class Cm Font )
the font to use for this button label.
.El
.Sh FILES
.Bl -tag -width Ds -compact
.It Pa /usr/X11R6/share/X11/app-defaults/SshAskpass
The default application resources.
.El
.Sh SEE ALSO
.Xr ssh 1 ,
.Xr ssh-agent 1 ,
.Xr X 7
.Sh LICENSE
Some portions of
.Nm
are derived directly or indirectly
from portions of xscreensaver by Jamie Zawinski
.Aq jwz@jwz.org ,
while others are original works.
.Pp
xscreensaver, Copyright \(co 1991-1999 Jamie Zawinski
.Aq jwz@jwz.org
.Pp
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear in
supporting documentation.
No representations are made about the suitability of this software
for any purpose.
It is provided "as is" without express or implied warranty.
.Pp
The remaining portions fall under the following copyright and license:
.Pp
.Nm
by Jim Knoble
.Aq jmknoble@jmknoble.cx
Copyright \(co 1999,2000,2001 Jim Knoble
.Pp
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear in
supporting documentation.