x11vnc: -unixpw on *bsd, hpux and tru64. -unixpw_nis mode. stunnel and gui tweaks.

pull/1/head
runge 18 years ago
parent b03a920cb9
commit a9a9c812f7

@ -175,6 +175,21 @@ if test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then
esac
fi
# only x11vnc uses crypt()
AH_TEMPLATE(HAVE_LIBCRYPT, [libcrypt library present])
AC_ARG_WITH(crypt,
[ --without-crypt disable support for libcrypt],,)
if test "x$with_crypt" != "xno"; then
AC_CHECK_FUNCS([crypt], HAVE_LIBC_CRYPT="true")
if test -z "$HAVE_LIBC_CRYPT"; then
AC_CHECK_LIB(crypt, crypt,
X_PRELIBS="$X_PRELIBS -lcrypt"
[AC_DEFINE(HAVE_LIBCRYPT)], ,
$X_LIBS $X_PRELIBS -lcrypt $X_EXTRA_LIBS)
fi
fi
X_LIBS="$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS"
fi
fi
@ -345,7 +360,7 @@ AC_SUBST(WSOCKLIB)
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h pwd.h sys/wait.h utmpx.h termios.h sys/ioctl.h])
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h pwd.h sys/wait.h utmpx.h termios.h sys/ioctl.h sys/stropts.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

@ -1,3 +1,8 @@
2006-03-04 Karl Runge <runge@karlrunge.com>
* x11vnc: -unixpw on *bsd, hpux and tru64. Add -unixpw_nis for
non-shadow systems. check stunnel dying. check SSH_CONNECTION
in -unixpw. gui icon tweaks, unix username.
2006-03-02 Karl Runge <runge@karlrunge.com>
* x11vnc: more tweaks to -unixpw mode. Add -gone popup mode.
Change filexfer via -R. Tune SMALL_FOOTPRINT. gui fixes.

File diff suppressed because it is too large Load Diff

@ -10,6 +10,7 @@
#include "rates.h"
#include "screen.h"
#include "unixpw.h"
#include "scan.h"
/*
* routines for handling incoming, outgoing, etc connections
@ -78,7 +79,7 @@ int all_clients_initialized(void) {
char *list_clients(void) {
rfbClientIteratorPtr iter;
rfbClientPtr cl;
char *list, tmp[32];
char *list, tmp[256];
int count = 0;
if (!screen) {
@ -93,12 +94,12 @@ char *list_clients(void) {
/*
* each client:
* <id>:<ip>:<port>:<user>:<hostname>:<input>:<loginview>,
* 8+1+16+1+5+1+24+1+256+1+5+1+1+1
* <id>:<ip>:<port>:<user>:<unix>:<hostname>:<input>:<loginview>:<time>,
* 8+1+64+1+5+1+24+1+24+1+256+1+5+1+1+1+10+1
* 123.123.123.123:60000/0x11111111-rw,
* so count+1 * 400 must cover it.
* so count+1 * 500 must cover it.
*/
list = (char *) malloc((count+1)*400);
list = (char *) malloc((count+1)*500);
list[0] = '\0';
@ -114,18 +115,27 @@ char *list_clients(void) {
strcat(list, ":");
sprintf(tmp, "%d:", cd->client_port);
strcat(list, tmp);
if (*(cd->username) == '\0') {
if (cd->username[0] == '\0') {
char *s = ident_username(cl);
if (s) free(s);
}
strcat(list, cd->username);
strcat(list, ":");
if (cd->unixname[0] == '\0') {
strcat(list, "none");
} else {
strcat(list, cd->unixname);
}
strcat(list, ":");
strcat(list, cd->hostname);
strcat(list, ":");
strcat(list, cd->input);
strcat(list, ":");
sprintf(tmp, "%d", cd->login_viewonly);
strcat(list, tmp);
strcat(list, ":");
sprintf(tmp, "%d", (int) cd->login_time);
strcat(list, tmp);
}
rfbReleaseClientIterator(iter);
return list;
@ -511,6 +521,10 @@ static void free_client_data(rfbClientPtr client) {
free(cd->username);
cd->username = NULL;
}
if (cd->unixname) {
free(cd->unixname);
cd->unixname = NULL;
}
}
free(client->clientData);
client->clientData = NULL;
@ -828,6 +842,9 @@ static unsigned char t2x2_bits[] = {
sprintf(str_y, "OK");
sprop = "x11vnc client disconnected";
h = 110;
str1 = "";
str2 = "";
str3 = "";
} else if (!strcmp(mode, "mouse_only")) {
str1 = str1_m;
str2 = str2_m;
@ -1747,6 +1764,7 @@ enum rfbNewClientAction new_client(rfbClientPtr client) {
cd->server_ip = get_local_host(client->sock);
cd->hostname = ip2host(client->host);
cd->username = strdup("");
cd->unixname = strdup("");
cd->input[0] = '-';
cd->login_viewonly = -1;
@ -1947,7 +1965,6 @@ void check_new_clients(void) {
int run_after_accept = 0;
if (unixpw_in_progress) {
int present = 0;
if (time(0) > unixpw_last_try_time + 30) {
rfbLog("unixpw_deny: timed out waiting for reply.\n");
unixpw_deny();

@ -14,7 +14,7 @@
#define XEMBED_VERSION 0
#define XEMBED_MAPPED (1 << 0)
int icon_mode = 0; /* hack for -gui tray */
int icon_mode = 0; /* hack for -gui tray/icon */
char *icon_mode_file = NULL;
FILE *icon_mode_fh = NULL;
int icon_mode_socks[ICON_MODE_SOCKS];

@ -401,34 +401,38 @@ void print_help(int mode) {
" and last line be \"__BEGIN_VIEWONLY__\" to have 2\n"
" full-access passwords)\n"
"\n"
"-unixpw [list] Experimental option: use Unix username and password\n"
" authentication. x11vnc uses the su(1) program to verify\n"
" the user's password. [list] is an optional comma\n"
" separated list of allowed Unix usernames. See below\n"
" for per-user options that can be applied.\n"
"-unixpw [list] Use Unix username and password authentication. x11vnc\n"
" uses the su(1) program to verify the user's password.\n"
" [list] is an optional comma separated list of allowed\n"
" Unix usernames. See below for per-user options that\n"
" can be applied.\n"
"\n"
" A familiar \"login:\" and \"Password:\" dialog is\n"
" presented to the user on a black screen inside the\n"
" vncviewer. The connection is dropped if the user fails\n"
" to supply the correct password in 3 tries or does not\n"
" send one before a 20 second timeout. Existing clients\n"
" send one before a 25 second timeout. Existing clients\n"
" are view-only during this period.\n"
"\n"
" Since the detailed behavior of su(1) can vary from\n"
" OS to OS and for local configurations, please test\n"
" the mode carefully on your systems before using it.\n"
" Try different combinations of valid/invalid usernames\n"
" and passwords.\n"
" E.g. try different combinations of valid/invalid\n"
" usernames and valid/invalid passwords to see if it\n"
" behaves correctly. x11vnc will be conservative and\n"
" reject a user if anything abnormal occurs.\n"
" \n"
" For example, on FreeBSD and the other BSD's and Tru64\n"
" it does not appear to be possible for the user running\n"
" x11vnc to validate his *own* password via su(1).\n"
" The x11vnc login will always fail in this case.\n"
" A possible workaround would be to start x11vnc as\n"
" root with the \"-users +nobody\" option to immediately\n"
" switch to user nobody. Another source of problems are\n"
" PAM modules that prompt for extra info, e.g. password\n"
" aging modules. These logins will always fail as well.\n"
" For example, on FreeBSD and the other BSD's by default\n"
" it is impossible for the user running x11vnc to validate\n"
" his *own* password via su(1) (evidently commenting\n"
" out the pam_self.so entry in /etc/pam.d/su eliminates\n"
" the problem). So the x11vnc login will always fail for\n"
" this case. A possible workaround would be to start\n"
" x11vnc as root with the \"-users +nobody\" option to\n"
" immediately switch to user nobody. Another source of\n"
" problems are PAM modules that prompt for extra info,\n"
" e.g. password aging modules. These logins will always\n"
" fail as well.\n"
"\n"
" *IMPORTANT*: to prevent the Unix password being sent in\n"
" *clear text* over the network, two x11vnc options are\n"
@ -444,17 +448,18 @@ void print_help(int mode) {
" Set UNIXPW_DISABLE_STUNNEL=1 to disable using -stunnel.\n"
" Evidently you will be using a different method to\n"
" encrypt the data between the vncviewer and x11vnc:\n"
" e.g. ssh(1) or a VPN. Note that use of ssh(1) with\n"
" -localhost is roughly the same as requiring a Unix\n"
" user login (since Unix password or the user's public\n"
" key authentication is used by ssh)\n"
"\n"
" As a convenience, if you ssh(1) in and start x11vnc\n"
" it will look to see if the environment variable\n"
" SSH_CONNECTION is set and appears reasonable. If it\n"
" does, then the stunnel requirement is dropped since\n"
" it is assumed you are using ssh for the encrypted\n"
" tunnelling. Use -stunnel to force stunnel usage.\n"
" e.g. ssh(1) or a VPN. Note that use of -localhost\n"
" with ssh(1) is roughly the same as requiring a Unix\n"
" user login (since a Unix password or the user's public\n"
" key authentication is used by ssh on the machine where\n"
" x11vnc runs and only local connections are accepted)\n"
"\n"
" As a convenience, if you ssh(1) in and start x11vnc it\n"
" will check if the environment variable SSH_CONNECTION\n"
" is set and appears reasonable. If it does, then the\n"
" stunnel requirement is dropped since it is assumed\n"
" you are using ssh for the encrypted tunnelling.\n"
" Use -stunnel to force stunnel usage.\n"
"\n"
" Set UNIXPW_DISABLE_LOCALHOST=1 to disable the -localhost\n"
" requirement. One should never do this (i.e. allow the\n"
@ -471,16 +476,28 @@ void print_help(int mode) {
" where \"opts\" is a \"+\" separated list of\n"
" \"viewonly\", \"fullaccess\", \"input=XXXX\", or\n"
" \"deny\", e.g. \"karl,fred:viewonly,boss:input=M\".\n"
" For \"input=\" it is the K,M,B,C describe under -input.\n"
"\n"
" If a user in the list is \"*\" that means those options\n"
" apply to all users. It also means all users are allowed\n"
" to log in. Use \"deny\" to explicitly deny some users\n"
" if you use \"*\" to set a global option.\n"
"\n"
"-stunnel [pem] Use the stunnel(1) (www.stunnel.org) to provide an\n"
" encrypted SSL tunnel between viewers and x11vnc.\n"
" This requires stunnel be installed on the system and\n"
" For \"input=\" it is the K,M,B,C described under -input.\n"
"\n"
" If a user in the list is \"*\" that means those\n"
" options apply to all users. It also means all users\n"
" are allowed to log in after supplying a valid password.\n"
" Use \"deny\" to explicitly deny some users if you use\n"
" \"*\" to set a global option.\n"
"\n"
"-unixpw_nis [list] As -unixpw above, however do not run su(1) but rather\n"
" use the traditional getpwnam() + crypt() method instead.\n"
" This requires that the encrpyted passwords be readable.\n"
" Passwords stored in /etc/shadow will be inaccessible\n"
" unless run as root. This is called \"NIS\" mode\n"
" simply because in most NIS setups the user encrypted\n"
" passwords are accessible (e.g. \"ypcat passwd\").\n"
" NIS is not required for this mode to work, but it\n"
" is unlikely it will work for any other environment.\n"
" All of the -unixpw options and contraints apply.\n"
"\n"
"-stunnel [pem] Use the stunnel(1) (www.stunnel.org) to provide\n"
" an encrypted SSL tunnel between viewers and x11vnc.\n"
" This requires stunnel to be installed on the system and\n"
" available via PATH (n.b. stunnel is often installed in\n"
" sbin directories). Version 4.x of stunnel is assumed;\n"
" see -stunnel3 below.\n"
@ -492,9 +509,9 @@ void print_help(int mode) {
"\n"
" stunnel is started up as a child process of x11vnc and\n"
" any SSL connections stunnel receives are decrypted and\n"
" sent to x11vnc over a local socket. The strings \"The\n"
" SSL VNC desktop is ...\" and SSLPORT=... are printed\n"
" out at startup.\n"
" sent to x11vnc over a local socket. The strings\n"
" \"The SSL VNC desktop is ...\" and \"SSLPORT=...\"\n"
" are printed out at startup.\n"
"\n"
" The -localhost option is enforced by default to\n"
" avoid people routing around the SSL channel. Set\n"
@ -502,7 +519,7 @@ void print_help(int mode) {
"\n"
" Your VNC viewer will need to be able to connect via SSL.\n"
" Unfortunately not too many do this. UltraVNC seems to\n"
" have a SSL plugin. It is not too difficult to set up\n"
" have a SSL plugin. It is not too difficult to set up\n"
" an stunnel or other SSL tunnel on the viewer side.\n"
"\n"
" A simple example on Unix using stunnel 3.x is:\n"
@ -2100,16 +2117,17 @@ void print_help(int mode) {
" http_url auth xauth users rootshift clipshift\n"
" scale_str scaled_x scaled_y scale_numer scale_denom\n"
" scale_fac scaling_blend scaling_nomult4 scaling_pad\n"
" scaling_interpolate inetd privremote unsafe safer nocmds\n"
" passwdfile unixpw unixpw_list stunnel stunnel_pem\n"
" using_shm logfile o flag rc norc h help V version\n"
" lastmod bg sigpipe threads readrate netrate netlatency\n"
" pipeinput clients client_count pid ext_xtest ext_xtrap\n"
" ext_xrecord ext_xkb ext_xshm ext_xinerama ext_overlay\n"
" ext_xfixes ext_xdamage ext_xrandr rootwin num_buttons\n"
" button_mask mouse_x mouse_y bpp depth indexed_color\n"
" dpy_x dpy_y wdpy_x wdpy_y off_x off_y cdpy_x cdpy_y\n"
" coff_x coff_y rfbauth passwd viewpasswd\n"
" scaling_interpolate inetd privremote unsafe safer\n"
" nocmds passwdfile unixpw unixpw_nis unixpw_list stunnel\n"
" stunnel_pem using_shm logfile o flag rc norc h help\n"
" V version lastmod bg sigpipe threads readrate netrate\n"
" netlatency pipeinput clients client_count pid ext_xtest\n"
" ext_xtrap ext_xrecord ext_xkb ext_xshm ext_xinerama\n"
" ext_overlay ext_xfixes ext_xdamage ext_xrandr rootwin\n"
" num_buttons button_mask mouse_x mouse_y bpp depth\n"
" indexed_color dpy_x dpy_y wdpy_x wdpy_y off_x off_y\n"
" cdpy_x cdpy_y coff_x coff_y rfbauth passwd viewpasswd\n"
"\n"
"-QD variable Just like -query variable, but returns the default\n"
" value for that parameter (no running x11vnc server\n"
" is consulted)\n"

@ -288,6 +288,9 @@ char *ident_username(rfbClientPtr client) {
}
user = newuser;
}
if (!strcmp(user, "unknown-user") && cd && cd->unixname[0] != '\0') {
user = cd->unixname;
}
newhost = ip2host(client->host);
len = strlen(user) + 1 + strlen(newhost) + 1;
str = (char *) malloc(len);
@ -318,7 +321,20 @@ int have_ssh_env(void) {
char *str, *p = getenv("SSH_CONNECTION");
char *rhost, *rport, *lhost, *lport;
if (! p) return 0;
if (! p) {
char *q = getenv("SSH_CLIENT");
if (! q) {
return 0;
}
if (strstr(q, "127.0.0.1") != NULL) {
return 0;
}
return 1;
}
if (strstr(p, "127.0.0.1") != NULL) {
return 0;
}
str = strdup(p);
@ -342,10 +358,10 @@ int have_ssh_env(void) {
if (0) fprintf(stderr, "%d/%d - '%s' '%s'\n", atoi(rport), atoi(lport), rhost, lhost);
if (atoi(rport) < 0 || atoi(rport) > 65535) {
if (atoi(rport) <= 16 || atoi(rport) > 65535) {
goto fail;
}
if (atoi(lport) < 0 || atoi(lport) > 65535) {
if (atoi(lport) <= 16 || atoi(lport) > 65535) {
goto fail;
}
@ -358,7 +374,6 @@ if (0) fprintf(stderr, "%d/%d - '%s' '%s'\n", atoi(rport), atoi(lport), rhost, l
return 1;
fail:
fprintf(stderr, "failed:\n");
free(str);

@ -16,6 +16,7 @@ int logfile_append = 0;
char *flagfile = NULL; /* -flag */
char *passwdfile = NULL; /* -passwdfile */
int unixpw = 0; /* -unixpw */
int unixpw_nis = 0; /* -unixpw_nis */
char *unixpw_list = NULL;
int use_stunnel = 0; /* -stunnel */
int stunnel_port = 0;

@ -16,6 +16,7 @@ extern int logfile_append;
extern char *flagfile;
extern char *passwdfile;
extern int unixpw;
extern int unixpw_nis;
extern char *unixpw_list;
extern int use_stunnel;
extern int stunnel_port;

@ -3704,6 +3704,8 @@ char *process_remote_cmd(char *cmd, int stringonly) {
snprintf(buf, bufn, "aro=%s:%s", p, NONUL(passwdfile));
} else if (!strcmp(p, "unixpw")) {
snprintf(buf, bufn, "aro=%s:%d", p, unixpw);
} else if (!strcmp(p, "unixpw_nis")) {
snprintf(buf, bufn, "aro=%s:%d", p, unixpw_nis);
} else if (!strcmp(p, "unixpw_list")) {
snprintf(buf, bufn, "aro=%s:%s", p, NONUL(unixpw_list));
} else if (!strcmp(p, "stunnel")) {

@ -19,6 +19,27 @@ void setup_stunnel(int rport, int *argc, char **argv);
static pid_t stunnel_pid = 0;
void check_stunnel(void) {
static time_t last_check = 0;
time_t now = time(0);
if (last_check + 3 >= now) {
return;
}
last_check = now;
if (stunnel_pid > 0) {
int status;
waitpid(stunnel_pid, &status, WNOHANG);
if (kill(stunnel_pid, 0) != 0) {
waitpid(stunnel_pid, &status, WNOHANG);
rfbLog("stunnel subprocess %d died.\n", stunnel_pid);
stunnel_pid = 0;
clean_up_exit(1);
}
}
}
int start_stunnel(int stunnel_port, int x11vnc_port) {
#ifdef SSLCMDS
char extra[] = ":/usr/sbin:/usr/local/sbin";

@ -3,6 +3,7 @@
/* -- sslcmds.h -- */
extern void check_stunnel(void);
extern int start_stunnel(int stunnel_port, int x11vnc_port);
extern void stop_stunnel(void);
extern void setup_stunnel(int rport, int *argc, char **argv);

@ -258,6 +258,8 @@ Permissions
=F rfbauth:
unixpw
unixpw_list:
unixpw_nis
unixpw_nis_list:
=0 storepasswd
=GAL LOFF
=GAL Misc-Perms::
@ -523,7 +525,11 @@ Set the -xrandr mode value.
"
set helptext(unixpw_list) "
Set the -unixpw_list usernames list value.
Set the -unixpw usernames list value.
"
set helptext(unixpw_nis_list) "
Set the -unixpw_nis usernames list value.
"
set helptext(stunnel_pem) "
@ -658,10 +664,12 @@ to apply the changes, or press \"Cancel\" to skip applying them.
remote-control commands.
- \"Password\" lets you set the session password viewers may use to gain full
access to the display.
access to the display. This will only work if x11vnc was started with
the -gui icon or -gui tray mode.
- \"ViewOnly Password\" lets you set the session password viewers may
use to gain view only access to the display.
use to gain view only access to the display. This will only work if
x11vnc was started with the -gui icon or -gui tray mode.
NOTE: These \"session\" passwords only last for the current x11vnc
session (they are not remembered, see the -storepasswd, -passwdfile,
@ -3217,25 +3225,36 @@ proc client_dialog {client} {
set ip ""
global menu_var text_area cleanup_window item_bool
append_text "\nClient info string: $client\n\n"
if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \
$client m0 m1 m2 m3 m4 m5 m6 m7]} {
# id:ip:port:user:hostname:input:loginvo
set cid $m1
set ip $m2
#<id>:<ip>:<port>:<user>:<unix>:<hostname>:<input>:<loginview>:<time>
append_text "\nClient info string:\n - $client\n\n"
if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \
$client m0 m1 m2 m3 m4 m5 m6 m7 m8 m9]} {
set cid $m1
set ip $m2
set port $m3
set user $m4
set host $m5
set unix $m5
set host $m6
regsub {\..*$} $host "" host
set input $m6
set logvo $m7
append_text "Host: $host, Port: $port, User: $user, IP: $ip, Id: $cid\n"
set input $m7
set logvo $m8
set ltime $m9
append_text "Host: $host, Port: $port, User: $user"
if {$unix != "" && $unix != "none"} {
append_text ", Unix: $unix"
}
append_text ", IP: $ip, Id: $cid\n"
append_text " - originally logged in as: "
if {$logvo == "1" } {
append_text "View-Only Client\n"
append_text "View-Only Client"
} else {
append_text "Normal Client\n"
append_text "Normal Client"
}
if {$ltime != ""} {
set tim [clock format $ltime]
append_text ", $tim"
}
append_text "\n"
append_text " - currently allowed input: "
set sk 0
set sm 0
@ -3303,22 +3322,30 @@ proc disconnect_dialog {client} {
set cid ""
set host ""
set msg "\n"
append msg "*** Client info string: $client\n"
if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*)$} $client m0 m1 m2 m3 m4 m5 m6]} {
set cid $m1
set ip $m2
append msg "*** Client info string:\n $client\n"
if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \
$client m0 m1 m2 m3 m4 m5 m6 m7 m8 m9]} {
set cid $m1
set ip $m2
set port $m3
set host $m4
set user $m4
set unix $m5
set host $m6
regsub {\..*$} $host "" host
set input $m5
set logvo $m6
append_text "Host: $host, Port: $port, IP: $ip, Id: $cid\n"
set input $m7
set logvo $m8
set ltime $m9
append_text "Host: $host, Port: $port, IP: $ip, User: $user"
if {$unix != "" && $unix != "none"} {
append_text ", Unix: $unix"
}
append_text ", Id: $cid\n"
}
if {$cid == ""} {
append_text "Invalid client info string: $client\n"
return
}
append msg "*** To *DISCONNECT* this client press \"OK\", otherwise press \"Cancel\"\n"
append msg "*** To *DISCONNECT* this client press \"OK\" again, otherwise press \"Cancel\"\n"
bell
if {[warning_dialog $msg "current"]} {
push_new_value "disconnect" "disconnect" $cid 1
@ -3389,12 +3416,19 @@ proc update_clients_menu {list} {
}
regsub -all {[{}()~!$&*|;'"`{}<>\[\]]} $client "" client
#'
if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \
$client m0 m1 m2 m3 m4 m5 m6 m7]} {
# id:ip:port:user:hostname:input:loginvo
set host $m5
if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \
$client m0 m1 m2 m3 m4 m5 m6 m7 m8 m9]} {
set id $m1
set user $m4
set unix $m5
set host $m6
regsub {\..*$} $host "" host
set clabel "$host $m1"
set clabel "$host $id"
if {$unix != "" && $unix != "none"} {
set clabel "$unix@$clabel"
} elseif {$user != "unknown-user"} {
set clabel "$user@$clabel"
}
} else {
regsub {:.*$} $client "" clabel
}
@ -3943,6 +3977,7 @@ proc do_props {{msg ""}} {
global menu_var unset_str
global have_labelframes ffont bfont
global props_buttons icon_noadvanced
global icon_mode icon_mode_at_startup
check_update_vars
@ -4054,6 +4089,7 @@ proc do_props {{msg ""}} {
entry $vp.e -show "*" -textvariable props_viewpasswd -font $bfont
pack $vp.e -fill x -expand 1 -padx 1m -pady 1m -side top
lappend props_buttons $vp.e
set pw "$w.passwd"
@ -4068,6 +4104,17 @@ proc do_props {{msg ""}} {
entry $pw.e -show "*" -textvariable props_passwd -font $bfont
pack $pw.e -fill x -expand 1 -padx 1m -pady 1m -side top
if {! $icon_mode_at_startup} {
$vp.e configure -state disabled
catch {$vp.l configure -state disabled}
catch {$vp configure -state disabled}
catch {$vp configure -foreground grey60}
$pw.e configure -state disabled
catch {$pw.l configure -state disabled}
catch {$pw configure -state disabled}
catch {$pw configure -foreground grey60}
}
lappend props_buttons $pw.e
set sh "$w.shared"
@ -4188,7 +4235,8 @@ proc popup_post {m} {
continue
}
if {[regexp {^([^:]*):(.*)$} $client mat id lab]} {
$wd add command -label "$lab" \
set nid [expr "$id + 0"]
$wd add command -label "$nid $lab" \
-command "do_disconnect_client $id"
}
}
@ -4213,26 +4261,38 @@ proc set_client_balloon {str} {
set client_balloon "$vnc_display"
set count 0
regsub -all {^.*aro=clients:} $str "" str
regsub -all {aro=.*$} $str "" str
regsub -all {ans=.*$} $str "" str
foreach client [split $str ","] {
if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \
$client m0 m1 m2 m3 m4 m5 m6 m7]} {
# id:ip:port:user:hostname:input:loginvo
#puts "client: $client"
if [regexp {^[ ]*$} $client] {
continue
}
if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \
$client m0 m1 m2 m3 m4 m5 m6 m7 m8 m9]} {
set id $m1
set nid [expr "$m1 + 0"]
set ip $m2
set port $m3
set user $m4
set unix $m5
if {[string length $user] >= 24} {
# weird identd hash...
set user [string range $user 0 8]
set user "${user}..."
}
set host $m5
set input $m6
set vo $m7
if {$unix != "" && $unix != "none"} {
set user $unix
}
set host $m6
set input $m7
set vo $m8
set ltime $m9
if [regexp {^[ ]*$} $host] {
set host $ip
}
set client_balloon "${client_balloon}\n$user\@$host"
set client_balloon "${client_balloon}\n$nid $user\@$host"
if {$vo == "1"} {
set client_balloon "${client_balloon} - view"
lappend client_id_list "$id:$user\@$host - view"
@ -5408,6 +5468,8 @@ proc get_nitem {item} {
set nitem "xrandr"
} elseif {$nitem == "unixpw_list"} {
set nitem "unixpw"
} elseif {$nitem == "unixpw_nis_list"} {
set nitem "unixpw_nis"
} elseif {$nitem == "stunnel_pem"} {
set nitem "stunnel"
} elseif {$nitem == "wireframe_mode"} {
@ -5870,12 +5932,16 @@ proc setup_tray_embed {} {
proc restart_everything {gui_mode} {
global env gui_argv0 x11vnc_prog full_win
global icon_mode_at_startup
global tray_embed tray_running
if {$gui_mode == "full"} {
set env(X11VNC_ICON_MODE) 0
} elseif {$gui_mode == "icon"} {
set env(X11VNC_ICON_MODE) 1
} elseif {$gui_mode == "tray"} {
if {![regexp -nocase {TRAY} $env(X11VNC_ICON_MODE)]} {
if {$tray_running} {
set env(X11VNC_ICON_MODE) "RUNNING"
} else {
set env(X11VNC_ICON_MODE) "TRAY"
}
}
@ -5957,7 +6023,8 @@ global connected_to_x11vnc
global delay_sleep extra_sleep extra_sleep_split
global cache_all_query_vars
global last_query_all_time query_all_freq client_tail client_sock client_info_read
global icon_mode tray_embed tray_running icon_setpasswd icon_embed_id
global icon_mode icon_mode_at_startup
global tray_embed tray_running icon_setpasswd icon_embed_id
global icon_noadvanced icon_minimal
global make_gui_count text_area_str
global gui_argv0 gui_start_mode
@ -6144,6 +6211,20 @@ if {[info exists env(X11VNC_SIMPLE_GUI)]} {
set icon_mode 0
set tray_embed 0
set tray_running 0
if {![info exists env(X11VNC_ICON_MODE_AT_STARTUP)]} {
if {[info exists env(X11VNC_ICON_MODE)]} {
if {$env(X11VNC_ICON_MODE) != 0} {
set env(X11VNC_ICON_MODE_AT_STARTUP) 1
} else {
set env(X11VNC_ICON_MODE_AT_STARTUP) 0
}
} else {
set env(X11VNC_ICON_MODE_AT_STARTUP) 0
}
}
set icon_mode_at_startup $env(X11VNC_ICON_MODE_AT_STARTUP)
if {![info exists env(X11VNC_ICON_MODE)]} {
set icon_mode 0
} elseif {$env(X11VNC_ICON_MODE) == "" || $env(X11VNC_ICON_MODE) == "0"} {
@ -6158,6 +6239,7 @@ if {![info exists env(X11VNC_ICON_MODE)]} {
set tray_running 1
}
}
set icon_setpasswd 0
if {[info exists env(X11VNC_ICON_SETPASS)]} {
if {$env(X11VNC_ICON_SETPASS) != ""} {

@ -269,6 +269,8 @@ char gui_code[] = "";
" =F rfbauth:\n"
" unixpw\n"
" unixpw_list:\n"
" unixpw_nis\n"
" unixpw_nis_list:\n"
" =0 storepasswd\n"
" =GAL LOFF\n"
" =GAL Misc-Perms::\n"
@ -534,7 +536,11 @@ char gui_code[] = "";
"\"\n"
"\n"
" set helptext(unixpw_list) \"\n"
"Set the -unixpw_list usernames list value.\n"
"Set the -unixpw usernames list value.\n"
"\"\n"
"\n"
" set helptext(unixpw_nis_list) \"\n"
"Set the -unixpw_nis usernames list value.\n"
"\"\n"
"\n"
" set helptext(stunnel_pem) \"\n"
@ -669,10 +675,12 @@ char gui_code[] = "";
" remote-control commands.\n"
"\n"
" - \\\"Password\\\" lets you set the session password viewers may use to gain full\n"
" access to the display.\n"
" access to the display. This will only work if x11vnc was started with \n"
" the -gui icon or -gui tray mode.\n"
" \n"
" - \\\"ViewOnly Password\\\" lets you set the session password viewers may\n"
" use to gain view only access to the display.\n"
" use to gain view only access to the display. This will only work if\n"
" x11vnc was started with the -gui icon or -gui tray mode.\n"
"\n"
"NOTE: These \\\"session\\\" passwords only last for the current x11vnc\n"
"session (they are not remembered, see the -storepasswd, -passwdfile,\n"
@ -3228,25 +3236,36 @@ char gui_code[] = "";
" set ip \"\"\n"
" global menu_var text_area cleanup_window item_bool\n"
"\n"
" append_text \"\\nClient info string: $client\\n\\n\"\n"
" if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \\\n"
" $client m0 m1 m2 m3 m4 m5 m6 m7]} {\n"
" # id:ip:port:user:hostname:input:loginvo\n"
" set cid $m1\n"
" set ip $m2\n"
" #<id>:<ip>:<port>:<user>:<unix>:<hostname>:<input>:<loginview>:<time>\n"
" append_text \"\\nClient info string:\\n - $client\\n\\n\"\n"
" if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \\\n"
" $client m0 m1 m2 m3 m4 m5 m6 m7 m8 m9]} {\n"
" set cid $m1\n"
" set ip $m2\n"
" set port $m3\n"
" set user $m4\n"
" set host $m5\n"
" set unix $m5\n"
" set host $m6\n"
" regsub {\\..*$} $host \"\" host\n"
" set input $m6\n"
" set logvo $m7\n"
" append_text \"Host: $host, Port: $port, User: $user, IP: $ip, Id: $cid\\n\"\n"
" set input $m7\n"
" set logvo $m8\n"
" set ltime $m9\n"
" append_text \"Host: $host, Port: $port, User: $user\"\n"
" if {$unix != \"\" && $unix != \"none\"} {\n"
" append_text \", Unix: $unix\"\n"
" }\n"
" append_text \", IP: $ip, Id: $cid\\n\"\n"
" append_text \" - originally logged in as: \"\n"
" if {$logvo == \"1\" } {\n"
" append_text \"View-Only Client\\n\"\n"
" append_text \"View-Only Client\"\n"
" } else {\n"
" append_text \"Normal Client\\n\"\n"
" append_text \"Normal Client\"\n"
" }\n"
" if {$ltime != \"\"} {\n"
" set tim [clock format $ltime]\n"
" append_text \", $tim\"\n"
" }\n"
" append_text \"\\n\"\n"
" append_text \" - currently allowed input: \"\n"
" set sk 0\n"
" set sm 0\n"
@ -3314,22 +3333,30 @@ char gui_code[] = "";
" set cid \"\"\n"
" set host \"\"\n"
" set msg \"\\n\"\n"
" append msg \"*** Client info string: $client\\n\"\n"
" if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*)$} $client m0 m1 m2 m3 m4 m5 m6]} {\n"
" set cid $m1\n"
" set ip $m2\n"
" append msg \"*** Client info string:\\n $client\\n\"\n"
" if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \\\n"
" $client m0 m1 m2 m3 m4 m5 m6 m7 m8 m9]} {\n"
" set cid $m1\n"
" set ip $m2\n"
" set port $m3\n"
" set host $m4\n"
" set user $m4\n"
" set unix $m5\n"
" set host $m6\n"
" regsub {\\..*$} $host \"\" host\n"
" set input $m5\n"
" set logvo $m6\n"
" append_text \"Host: $host, Port: $port, IP: $ip, Id: $cid\\n\"\n"
" set input $m7\n"
" set logvo $m8\n"
" set ltime $m9\n"
" append_text \"Host: $host, Port: $port, IP: $ip, User: $user\"\n"
" if {$unix != \"\" && $unix != \"none\"} {\n"
" append_text \", Unix: $unix\"\n"
" }\n"
" append_text \", Id: $cid\\n\"\n"
" }\n"
" if {$cid == \"\"} {\n"
" append_text \"Invalid client info string: $client\\n\"\n"
" return\n"
" }\n"
" append msg \"*** To *DISCONNECT* this client press \\\"OK\\\", otherwise press \\\"Cancel\\\"\\n\"\n"
" append msg \"*** To *DISCONNECT* this client press \\\"OK\\\" again, otherwise press \\\"Cancel\\\"\\n\"\n"
" bell\n"
" if {[warning_dialog $msg \"current\"]} {\n"
" push_new_value \"disconnect\" \"disconnect\" $cid 1\n"
@ -3400,12 +3427,19 @@ char gui_code[] = "";
" }\n"
" regsub -all {[{}()~!$&*|;'\"`{}<>\\[\\]]} $client \"\" client\n"
" #'\n"
" if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \\\n"
" $client m0 m1 m2 m3 m4 m5 m6 m7]} {\n"
" # id:ip:port:user:hostname:input:loginvo\n"
" set host $m5\n"
" if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \\\n"
" $client m0 m1 m2 m3 m4 m5 m6 m7 m8 m9]} {\n"
" set id $m1\n"
" set user $m4\n"
" set unix $m5\n"
" set host $m6\n"
" regsub {\\..*$} $host \"\" host\n"
" set clabel \"$host $m1\"\n"
" set clabel \"$host $id\"\n"
" if {$unix != \"\" && $unix != \"none\"} {\n"
" set clabel \"$unix@$clabel\"\n"
" } elseif {$user != \"unknown-user\"} {\n"
" set clabel \"$user@$clabel\"\n"
" }\n"
" } else {\n"
" regsub {:.*$} $client \"\" clabel\n"
" }\n"
@ -3954,6 +3988,7 @@ char gui_code[] = "";
" global menu_var unset_str\n"
" global have_labelframes ffont bfont\n"
" global props_buttons icon_noadvanced\n"
" global icon_mode icon_mode_at_startup\n"
"\n"
" check_update_vars\n"
"\n"
@ -4065,6 +4100,7 @@ char gui_code[] = "";
" entry $vp.e -show \"*\" -textvariable props_viewpasswd -font $bfont\n"
" pack $vp.e -fill x -expand 1 -padx 1m -pady 1m -side top\n"
"\n"
"\n"
" lappend props_buttons $vp.e\n"
"\n"
" set pw \"$w.passwd\"\n"
@ -4079,6 +4115,17 @@ char gui_code[] = "";
" entry $pw.e -show \"*\" -textvariable props_passwd -font $bfont\n"
" pack $pw.e -fill x -expand 1 -padx 1m -pady 1m -side top\n"
"\n"
" if {! $icon_mode_at_startup} {\n"
" $vp.e configure -state disabled\n"
" catch {$vp.l configure -state disabled}\n"
" catch {$vp configure -state disabled}\n"
" catch {$vp configure -foreground grey60}\n"
" $pw.e configure -state disabled\n"
" catch {$pw.l configure -state disabled}\n"
" catch {$pw configure -state disabled}\n"
" catch {$pw configure -foreground grey60}\n"
" }\n"
"\n"
" lappend props_buttons $pw.e\n"
"\n"
" set sh \"$w.shared\"\n"
@ -4199,7 +4246,8 @@ char gui_code[] = "";
" continue\n"
" }\n"
" if {[regexp {^([^:]*):(.*)$} $client mat id lab]} {\n"
" $wd add command -label \"$lab\" \\\n"
" set nid [expr \"$id + 0\"]\n"
" $wd add command -label \"$nid $lab\" \\\n"
" -command \"do_disconnect_client $id\"\n"
" }\n"
" }\n"
@ -4224,26 +4272,38 @@ char gui_code[] = "";
" \n"
" set client_balloon \"$vnc_display\"\n"
" set count 0\n"
" regsub -all {^.*aro=clients:} $str \"\" str\n"
" regsub -all {aro=.*$} $str \"\" str\n"
" regsub -all {ans=.*$} $str \"\" str\n"
" foreach client [split $str \",\"] {\n"
" if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \\\n"
" $client m0 m1 m2 m3 m4 m5 m6 m7]} {\n"
" # id:ip:port:user:hostname:input:loginvo\n"
" #puts \"client: $client\"\n"
" if [regexp {^[ ]*$} $client] {\n"
" continue\n"
" }\n"
" if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \\\n"
" $client m0 m1 m2 m3 m4 m5 m6 m7 m8 m9]} {\n"
" set id $m1\n"
" set nid [expr \"$m1 + 0\"]\n"
" set ip $m2\n"
" set port $m3\n"
" set user $m4\n"
" set unix $m5\n"
" if {[string length $user] >= 24} {\n"
" # weird identd hash...\n"
" set user [string range $user 0 8]\n"
" set user \"${user}...\"\n"
" }\n"
" set host $m5\n"
" set input $m6\n"
" set vo $m7\n"
" if {$unix != \"\" && $unix != \"none\"} {\n"
" set user $unix\n"
" }\n"
" set host $m6\n"
" set input $m7\n"
" set vo $m8\n"
" set ltime $m9\n"
" if [regexp {^[ ]*$} $host] {\n"
" set host $ip\n"
" }\n"
" set client_balloon \"${client_balloon}\\n$user\\@$host\"\n"
" set client_balloon \"${client_balloon}\\n$nid $user\\@$host\"\n"
" if {$vo == \"1\"} {\n"
" set client_balloon \"${client_balloon} - view\"\n"
" lappend client_id_list \"$id:$user\\@$host - view\"\n"
@ -5419,6 +5479,8 @@ char gui_code[] = "";
" set nitem \"xrandr\"\n"
" } elseif {$nitem == \"unixpw_list\"} {\n"
" set nitem \"unixpw\"\n"
" } elseif {$nitem == \"unixpw_nis_list\"} {\n"
" set nitem \"unixpw_nis\"\n"
" } elseif {$nitem == \"stunnel_pem\"} {\n"
" set nitem \"stunnel\"\n"
" } elseif {$nitem == \"wireframe_mode\"} {\n"
@ -5881,12 +5943,16 @@ char gui_code[] = "";
"\n"
"proc restart_everything {gui_mode} {\n"
" global env gui_argv0 x11vnc_prog full_win\n"
" global icon_mode_at_startup\n"
" global tray_embed tray_running\n"
" if {$gui_mode == \"full\"} {\n"
" set env(X11VNC_ICON_MODE) 0\n"
" } elseif {$gui_mode == \"icon\"} {\n"
" set env(X11VNC_ICON_MODE) 1\n"
" } elseif {$gui_mode == \"tray\"} {\n"
" if {![regexp -nocase {TRAY} $env(X11VNC_ICON_MODE)]} {\n"
" if {$tray_running} {\n"
" set env(X11VNC_ICON_MODE) \"RUNNING\"\n"
" } else {\n"
" set env(X11VNC_ICON_MODE) \"TRAY\"\n"
" }\n"
" }\n"
@ -5968,7 +6034,8 @@ char gui_code[] = "";
"global delay_sleep extra_sleep extra_sleep_split\n"
"global cache_all_query_vars\n"
"global last_query_all_time query_all_freq client_tail client_sock client_info_read\n"
"global icon_mode tray_embed tray_running icon_setpasswd icon_embed_id\n"
"global icon_mode icon_mode_at_startup\n"
"global tray_embed tray_running icon_setpasswd icon_embed_id\n"
"global icon_noadvanced icon_minimal\n"
"global make_gui_count text_area_str\n"
"global gui_argv0 gui_start_mode\n"
@ -6155,6 +6222,20 @@ char gui_code[] = "";
"set icon_mode 0\n"
"set tray_embed 0\n"
"set tray_running 0\n"
"\n"
"if {![info exists env(X11VNC_ICON_MODE_AT_STARTUP)]} {\n"
" if {[info exists env(X11VNC_ICON_MODE)]} {\n"
" if {$env(X11VNC_ICON_MODE) != 0} {\n"
" set env(X11VNC_ICON_MODE_AT_STARTUP) 1\n"
" } else {\n"
" set env(X11VNC_ICON_MODE_AT_STARTUP) 0\n"
" }\n"
" } else {\n"
" set env(X11VNC_ICON_MODE_AT_STARTUP) 0\n"
" }\n"
"}\n"
"set icon_mode_at_startup $env(X11VNC_ICON_MODE_AT_STARTUP)\n"
"\n"
"if {![info exists env(X11VNC_ICON_MODE)]} {\n"
" set icon_mode 0\n"
"} elseif {$env(X11VNC_ICON_MODE) == \"\" || $env(X11VNC_ICON_MODE) == \"0\"} {\n"
@ -6169,6 +6250,7 @@ char gui_code[] = "";
" set tray_running 1\n"
" }\n"
"}\n"
"\n"
"set icon_setpasswd 0\n"
"if {[info exists env(X11VNC_ICON_SETPASS)]} {\n"
" if {$env(X11VNC_ICON_SETPASS) != \"\"} {\n"

@ -5,6 +5,7 @@
extern int grantpt(int);
extern int unlockpt(int);
extern char *ptsname(int);
extern char *crypt(const char*, const char *);
#endif
#include "x11vnc.h"
@ -14,11 +15,15 @@ extern char *ptsname(int);
#include <rfb/default8x16.h>
#if LIBVNCSERVER_HAVE_FORK
#if LIBVNCSERVER_HAVE_SYS_WAIT_H
#if LIBVNCSERVER_HAVE_WAITPID
#define UNIXPW
#if LIBVNCSERVER_HAVE_SYS_WAIT_H && LIBVNCSERVER_HAVE_WAITPID
#define UNIXPW_SU
#endif
#endif
#if LIBVNCSERVER_HAVE_PWD_H && LIBVNCSERVER_HAVE_GETPWNAM
#if LIBVNCSERVER_HAVE_CRYPT || LIBVNCSERVER_HAVE_LIBCRYPT
#define UNIXPW_CRYPT
#endif
#endif
#if LIBVNCSERVER_HAVE_SYS_IOCTL_H
@ -27,9 +32,10 @@ extern char *ptsname(int);
#if LIBVNCSERVER_HAVE_TERMIOS_H
#include <termios.h>
#endif
#if 0
#if LIBVNCSERVER_HAVE_SYS_STROPTS_H
#include <sys/stropts.h>
#endif
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
#define IS_BSD
#endif
@ -39,6 +45,7 @@ void unixpw_keystroke(rfbBool down, rfbKeySym keysym, int init);
void unixpw_accept(char *user);
void unixpw_deny(void);
int su_verify(char *user, char *pass);
int crypt_verify(char *user, char *pass);
static int white(void);
static int text_x(void);
@ -84,10 +91,17 @@ static int text_y(void) {
}
void unixpw_screen(int init) {
#ifndef UNIXPW
if (unixpw_nis) {
#ifndef UNIXPW_CRYPT
rfbLog("-unixpw_nis is not supported on this OS/machine\n");
clean_up_exit(1);
#endif
} else {
#ifndef UNIXPW_SU
rfbLog("-unixpw is not supported on this OS/machine\n");
clean_up_exit(1);
#endif
}
if (init) {
int x, y;
char log[] = "login: ";
@ -115,6 +129,8 @@ static char slave_str[MAXPATHLEN];
static char slave_str[4096];
#endif
static int used_get_pty_ptmx = 0;
char *get_pty_ptmx(int *fd_p) {
char *slave;
int fd = -1, i, ndevs = 4, tmp;
@ -130,7 +146,6 @@ char *get_pty_ptmx(int *fd_p) {
#if LIBVNCSERVER_HAVE_GRANTPT
for (i=0; i < ndevs; i++) {
#ifdef O_NOCTTY
fd = open(devs[i], O_RDWR|O_NOCTTY);
#else
@ -146,13 +161,6 @@ char *get_pty_ptmx(int *fd_p) {
return NULL;
}
#if 0
#if defined(FIONBIO)
tmp = 1;
ioctl(fd, FIONBIO, &tmp);
#endif
#endif
#if LIBVNCSERVER_HAVE_SYS_IOCTL_H && defined(TIOCPKT)
tmp = 0;
ioctl(fd, TIOCPKT, (char *) &tmp);
@ -180,8 +188,6 @@ char *get_pty_ptmx(int *fd_p) {
ioctl(fd, TIOCFLUSH, (char *) 0);
#endif
strcpy(slave_str, slave);
*fd_p = fd;
return slave_str;
@ -194,7 +200,6 @@ char *get_pty_ptmx(int *fd_p) {
char *get_pty_loop(int *fd_p) {
char *slave;
char master_str[16];
int fd = -1, i;
char c;
@ -233,6 +238,7 @@ char *get_pty_loop(int *fd_p) {
}
char *get_pty(int *fd_p) {
used_get_pty_ptmx = 0;
if (getenv("BSD_PTY")) {
return get_pty_loop(fd_p);
}
@ -240,6 +246,7 @@ char *get_pty(int *fd_p) {
return get_pty_loop(fd_p);
#else
#if LIBVNCSERVER_HAVE_GRANTPT
used_get_pty_ptmx = 1;
return get_pty_ptmx(fd_p);
#else
return get_pty_loop(fd_p);
@ -267,28 +274,76 @@ void try_to_be_nobody(void) {
setegid(pw->pw_gid);
#endif
}
#endif /* PWD_H */
}
static int slave_fd = -1;
static int slave_fd = -1, alarm_fired = 0;;
static void close_alarm (int sig) {
if (slave_fd >= 0) {
close(slave_fd);
}
alarm_fired = 1;
if (0) sig = 0; /* compiler warning */
}
static void kill_child (pid_t pid, int fd) {
int status;
slave_fd = -1;
alarm_fired = 0;
if (fd >= 0) {
close(fd);
}
kill(pid, SIGTERM);
waitpid(pid, &status, WNOHANG);
}
int crypt_verify(char *user, char *pass) {
#ifndef UNIXPW_CRYPT
return 0;
#else
struct passwd *pwd;
char *realpw, *cr;
int n;
pwd = getpwnam(user);
if (! pwd) {
return 0;
}
realpw = pwd->pw_passwd;
if (realpw == NULL || realpw[0] == '\0') {
return 0;
}
n = strlen(pass);
if (pass[n-1] == '\n') {
pass[n-1] = '\0';
}
cr = crypt(pass, realpw);
if (cr == NULL) {
return 0;
}
if (!strcmp(cr, realpw)) {
return 1;
} else {
return 0;
}
#endif /* UNIXPW_CRYPT */
}
int su_verify(char *user, char *pass) {
#ifndef UNIXPW
#ifndef UNIXPW_SU
return 0;
#else
int i, j, status, fd = -1, sfd, tfd;
int slow_pw = 1;
char *slave, *bin_true = NULL, *bin_su = NULL;
pid_t pid, pidw;
struct stat sbuf;
static int first = 1;
char instr[16];
char instr[32], buf[10];
if (first) {
set_db();
@ -316,7 +371,15 @@ int su_verify(char *user, char *pass) {
}
}
if (stat("/bin/su", &sbuf) == 0) {
#define SU_DEBUG 0
#if SU_DEBUG
if (stat("/su", &sbuf) == 0) {
bin_su = "/su"; /* Freesbie read-only-fs /bin/su not suid! */
#else
if (0) {
;
#endif
} else if (stat("/bin/su", &sbuf) == 0) {
bin_su = "/bin/su";
} else if (stat("/usr/bin/su", &sbuf) == 0) {
bin_su = "/usr/bin/su";
@ -337,10 +400,12 @@ int su_verify(char *user, char *pass) {
}
slave = get_pty(&fd);
if (slave == NULL) {
rfbLogPerror("get_pty failed.");
return 0;
}