mirror of
https://github.com/paulusmack/ppp.git
synced 2024-11-23 02:13:28 +08:00
Remove pppgetpass program
This is associated with the passprompt plugin, and like it, seems not to be very useful any more now that no-one uses dial-up. Also, its function seems somewhat peripheral to PPP. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
This commit is contained in:
parent
0a66ad22e5
commit
b9e627e212
@ -1,6 +1,6 @@
|
||||
ACLOCAL_AMFLAGS="-Im4"
|
||||
|
||||
SUBDIRS = chat contrib pppd pppstats pppdump
|
||||
SUBDIRS = chat pppd pppstats pppdump
|
||||
|
||||
if PPP_WITH_PLUGINS
|
||||
SUBDIRS += pppd/plugins
|
||||
|
11
configure.ac
11
configure.ac
@ -317,22 +317,11 @@ AM_COND_IF([PPP_WITH_FILTER], [
|
||||
])
|
||||
])
|
||||
|
||||
#
|
||||
# Some contributions require GTK/GLIB
|
||||
AC_ARG_WITH([gtk], AS_HELP_STRING([--with-gtk], [Build contributions with the GTK+ interface]))
|
||||
if test "x${with_gtk}" = "xyes"; then
|
||||
PKG_CHECK_MODULES([GTK], [gtk+-2.0])
|
||||
PKG_CHECK_MODULES([GLIB], [glib-2.0])
|
||||
fi
|
||||
AM_CONDITIONAL([WITH_GTK], test "x${with_gtk}" = "xyes")
|
||||
|
||||
AC_DEFINE_UNQUOTED(PPPD_VERSION, "$VERSION", [Version of pppd])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
chat/Makefile
|
||||
contrib/Makefile
|
||||
contrib/pppgetpass/Makefile
|
||||
include/Makefile
|
||||
pppd/Makefile
|
||||
pppd/pppd.pc
|
||||
|
@ -1 +0,0 @@
|
||||
SUBDIRS = pppgetpass
|
2
contrib/pppgetpass/.gitignore
vendored
2
contrib/pppgetpass/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
pppgetpass.vt
|
||||
pppgetpass.gtk
|
@ -1,17 +0,0 @@
|
||||
noinst_PROGRAMS = pppgetpass.vt
|
||||
|
||||
pppgetpass_vt_SOURCES = pppgetpass.vt.c
|
||||
pppgetpass_vt_CPPFLAGS = -Wno-unused-result
|
||||
|
||||
if WITH_GTK
|
||||
noinst_PROGRAMS += pppgetpass.gtk
|
||||
|
||||
pppgetpass_gtk_SOURCES = pppgetpass.gtk.c
|
||||
pppgetpass_gtk_CPPFLAGS = -Wno-deprecated-declarations -Wno-discarded-qualifiers
|
||||
pppgetpass_gtk_CPPFLAGS += $(GLIB_CFLAGS) $(GTK_CFLAGS)
|
||||
pppgetpass_gtk_LDADD = $(GLIB_LIBS) $(GTK_LIBS)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
pppgetpass.sh \
|
||||
pppgetpass.8
|
@ -1,18 +0,0 @@
|
||||
.TH PPPGETPASS 8 "26 Sep 1999"
|
||||
.SH NAME
|
||||
pppgetpass \- prompt for PAP password
|
||||
.SH SYNOPSIS
|
||||
.B pppgetpass
|
||||
.I client server fd
|
||||
.SH DESCRIPTION
|
||||
.B pppgetpass
|
||||
the outer half of a plugin for PAP password prompting in pppd.
|
||||
If the peer requires PAP, and the
|
||||
.B passprompt.so
|
||||
plugin is loaded into pppd, it will run
|
||||
.B /usr/sbin/pppgetpass
|
||||
(or another program specified by the
|
||||
.B promptprog
|
||||
option) to prompt the user for the password.
|
||||
.SH SEE ALSO
|
||||
pppd(8)
|
@ -1,92 +0,0 @@
|
||||
#include <glib.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkwindow.h>
|
||||
#include <gtk/gtkmain.h>
|
||||
#include <gtk/gtkbutton.h>
|
||||
#include <gtk/gtkvbox.h>
|
||||
#include <gtk/gtklabel.h>
|
||||
#include <gtk/gtkentry.h>
|
||||
#include <gtk/gtksignal.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <syslog.h>
|
||||
|
||||
int outfd;
|
||||
int err;
|
||||
|
||||
static void okpressed(void *widget, void *clientdata)
|
||||
{
|
||||
GtkWidget *answer=clientdata;
|
||||
gchar *pass;
|
||||
int passlen;
|
||||
ssize_t wrote;
|
||||
(void)widget;
|
||||
|
||||
pass=gtk_entry_get_text(GTK_ENTRY(answer));
|
||||
|
||||
passlen=strlen(pass);
|
||||
if(!passlen)
|
||||
return;
|
||||
|
||||
if((wrote=write(outfd, pass, passlen))!=passlen) {
|
||||
if(wrote<0)
|
||||
syslog(LOG_ERR, "write error on outpipe: %m");
|
||||
else
|
||||
syslog(LOG_ERR, "short write on outpipe");
|
||||
err=1;
|
||||
}
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GtkWidget *mainwindow, *vbox, *question, *answer, *ok;
|
||||
char buf[1024];
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
openlog(argv[0], LOG_PID, LOG_DAEMON);
|
||||
if(argc!=4) {
|
||||
syslog(LOG_WARNING, "Usage error");
|
||||
return 1;
|
||||
}
|
||||
outfd=atoi(argv[3]);
|
||||
mainwindow=gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(mainwindow), "pppgetpass");
|
||||
gtk_signal_connect(GTK_OBJECT(mainwindow), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_main_quit), 0);
|
||||
|
||||
vbox=gtk_vbox_new(FALSE, 5);
|
||||
gtk_container_add(GTK_CONTAINER(mainwindow), vbox);
|
||||
gtk_widget_show(vbox);
|
||||
|
||||
if(argv[1][0] && argv[2][0])
|
||||
snprintf(buf, sizeof buf, "Password for PPP client %s on server %s: ", argv[1], argv[2]);
|
||||
else if(argv[1][0] && !argv[2][0])
|
||||
snprintf(buf, sizeof buf, "Password for PPP client %s: ", argv[1]);
|
||||
else if(!argv[1][0] && argv[2][0])
|
||||
snprintf(buf, sizeof buf, "Password for PPP on server %s: ", argv[2]);
|
||||
else
|
||||
snprintf(buf, sizeof buf, "Enter PPP password: ");
|
||||
question=gtk_label_new(buf);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), question, FALSE, TRUE, 0);
|
||||
gtk_widget_show(question);
|
||||
|
||||
answer=gtk_entry_new();
|
||||
gtk_entry_set_visibility(GTK_ENTRY(answer), 0);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), answer, FALSE, TRUE, 0);
|
||||
gtk_widget_show(answer);
|
||||
|
||||
ok=gtk_button_new_with_label("OK");
|
||||
gtk_box_pack_start(GTK_BOX(vbox), ok, FALSE, TRUE, 0);
|
||||
gtk_signal_connect(GTK_OBJECT(ok), "clicked",
|
||||
GTK_SIGNAL_FUNC(okpressed), answer);
|
||||
gtk_widget_show(ok);
|
||||
|
||||
gtk_widget_show(mainwindow);
|
||||
gtk_main();
|
||||
|
||||
return err;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
exec pppgetpass.vt "$@"
|
||||
else
|
||||
exec pppgetpass.gtk "$@"
|
||||
fi
|
@ -1,218 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <syslog.h>
|
||||
#include <termios.h>
|
||||
#include <sys/vt.h>
|
||||
|
||||
static int console_owner(uid_t, int);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int console;
|
||||
uid_t uid;
|
||||
struct vt_stat origstate;
|
||||
int openvtnum;
|
||||
char openvtname[256];
|
||||
int openvt;
|
||||
gid_t gid;
|
||||
int chowned;
|
||||
FILE *fp;
|
||||
struct termios t;
|
||||
char pass[256], *nl;
|
||||
int outfd, passlen;
|
||||
ssize_t wrote;
|
||||
console=open("/dev/console", O_RDWR);
|
||||
|
||||
uid=getuid();
|
||||
gid=getgid();
|
||||
seteuid(uid);
|
||||
|
||||
openlog(argv[0], LOG_PID, LOG_DAEMON);
|
||||
|
||||
if(argc!=4) {
|
||||
syslog(LOG_WARNING, "Usage error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(console<0) {
|
||||
syslog(LOG_ERR, "open(/dev/console): %m");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(ioctl(console, VT_GETSTATE, &origstate)<0) {
|
||||
syslog(LOG_ERR, "VT_GETSTATE: %m");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(uid) {
|
||||
if(!console_owner(uid, origstate.v_active)) {
|
||||
int i;
|
||||
for(i=0;i<64;++i) {
|
||||
if(i!=origstate.v_active && console_owner(uid, i))
|
||||
break;
|
||||
}
|
||||
if(i==64) {
|
||||
syslog(LOG_WARNING, "run by uid %lu not at console", (unsigned long)uid);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ioctl(console, VT_OPENQRY, &openvtnum)<0) {
|
||||
syslog(LOG_ERR, "VT_OPENQRY: %m");
|
||||
return 1;
|
||||
}
|
||||
if(openvtnum==-1) {
|
||||
syslog(LOG_ERR, "No free VTs");
|
||||
return 1;
|
||||
}
|
||||
|
||||
snprintf(openvtname, sizeof openvtname, "/dev/tty%d", openvtnum);
|
||||
seteuid(0);
|
||||
openvt=open(openvtname, O_RDWR);
|
||||
if(openvt<0) {
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "open(%s): %m", openvtname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
chowned=fchown(openvt, uid, gid);
|
||||
if(chowned<0) {
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "fchown(%s): %m", openvtname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
close(console);
|
||||
|
||||
if(ioctl(openvt, VT_ACTIVATE, openvtnum)<0) {
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "VT_ACTIVATE(%d): %m", openvtnum);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while(ioctl(openvt, VT_WAITACTIVE, openvtnum)<0) {
|
||||
if(errno!=EINTR) {
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "VT_WAITACTIVE(%d): %m", openvtnum);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
seteuid(uid);
|
||||
fp=fdopen(openvt, "r+");
|
||||
if(!fp) {
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "fdopen(%s): %m", openvtname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(tcgetattr(openvt, &t)<0) {
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "tcgetattr(%s): %m", openvtname);
|
||||
return 1;
|
||||
}
|
||||
t.c_lflag &= ~ECHO;
|
||||
if(tcsetattr(openvt, TCSANOW, &t)<0) {
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "tcsetattr(%s): %m", openvtname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(fprintf(fp, "\033[2J\033[H")<0) {
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "write error on %s: %m", openvtname);
|
||||
return 1;
|
||||
}
|
||||
if(argv[1][0] && argv[2][0]) {
|
||||
if(fprintf(fp, "Password for PPP client %s on server %s: ", argv[1], argv[2])<0) {
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "write error on %s: %m", openvtname);
|
||||
return 1;
|
||||
}
|
||||
} else if(argv[1][0] && !argv[2][0]) {
|
||||
if(fprintf(fp, "Password for PPP client %s: ", argv[1])<0) {
|
||||
syslog(LOG_ERR, "write error on %s: %m", openvtname);
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
return 1;
|
||||
}
|
||||
} else if(!argv[1][0] && argv[2][0]) {
|
||||
if(fprintf(fp, "Password for PPP on server %s: ", argv[2])<0) {
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "write error on %s: %m", openvtname);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if(fprintf(fp, "Enter PPP password: ")<0) {
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
syslog(LOG_ERR, "write error on %s: %m", openvtname);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(!fgets(pass, sizeof pass, fp)) {
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
if(ferror(fp)) {
|
||||
syslog(LOG_ERR, "read error on %s: %m", openvtname);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if((nl=strchr(pass, '\n')))
|
||||
*nl=0;
|
||||
passlen=strlen(pass);
|
||||
|
||||
outfd=atoi(argv[3]);
|
||||
if((wrote=write(outfd, pass, passlen))!=passlen) {
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
if(wrote<0)
|
||||
syslog(LOG_ERR, "write error on outpipe: %m");
|
||||
else
|
||||
syslog(LOG_ERR, "short write on outpipe");
|
||||
return 1;
|
||||
}
|
||||
|
||||
seteuid(0);
|
||||
ioctl(openvt, VT_ACTIVATE, origstate.v_active);
|
||||
seteuid(uid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int console_owner(uid_t uid, int cons)
|
||||
{
|
||||
char name[256];
|
||||
struct stat st;
|
||||
snprintf(name, sizeof name, "/dev/tty%d", cons);
|
||||
if(stat(name, &st)<0) {
|
||||
if(errno!=ENOENT)
|
||||
syslog(LOG_ERR, "stat(%s): %m", name);
|
||||
return 0;
|
||||
}
|
||||
return uid==st.st_uid;
|
||||
}
|
Loading…
Reference in New Issue
Block a user