From 04d2ffae3e25ad79e5cd68bb436d882e16c6cf53 Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Wed, 15 Jan 2003 15:51:29 +0000 Subject: [w3m-dev 03639] Re: smb.cgi * Bonus/2ch.cgi: change password handling * Bonus/README: update * Bonus/README.eng: ditto --- Bonus/README | 11 ++++++--- Bonus/README.eng | 17 ++++++++------ Bonus/smb.cgi | 71 +++++++++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 78 insertions(+), 21 deletions(-) (limited to 'Bonus') diff --git a/Bonus/README b/Bonus/README index 31615e7..af019ce 100644 --- a/Bonus/README +++ b/Bonus/README @@ -15,9 +15,14 @@ smb.cgi SMB にアクセスする local CGI です。 nmblookup,smbclient を使うので sabma がインストールされている 必要があります。 - パスワードは、smbclient の -A オプションを使えるなら、 - smbclient -A ~/.w3m/smb として、使えない場合は ~/.w3m/smb を - 読んで環境変数 PASSWD で渡します。 + パスワードは、 + 1) ~/.w3m/smb にパスワードが設定されており、 + smbclient の -A オプションを使えるなら + smbclient -A ~/.w3m/smb として渡します。 + 2) 環境変数 PASSWD_FILE (パスワードのみのファイル)が設定 + されている場合は、環境変数 PASSWD_FILE を使います。 + 3) ~/.w3m/smb にパスワードが設定されていれば、 + 環境変数 PASSWD_FD を使って標準入力経由で渡します。 どちらにせよ、あまり良い事ではないので SMB(CIFS)プロトコルを 喋る版を希望。 diff --git a/Bonus/README.eng b/Bonus/README.eng index 2d83186..2f7507d 100644 --- a/Bonus/README.eng +++ b/Bonus/README.eng @@ -5,19 +5,22 @@ w3m file:/cgi-bin/2ch.cgi?http://pc.2ch.net/test/read.cgi/unix/1035755937/ - it uses wget -c - dat is recorded under ~/w3m2ch/ - You can post + It uses wget -c. + `dat' files are recorded under ~/w3m2ch/. + You can not post. smb.cgi [w3m-dev 03634] smb.cgi localcgi to access SMB. Since it uses nmblookup, smbclient, you should install samba. - Password can be configured in ~/.w3m/smb: - when -A option available smbclient -A ~/.w3m/smb - otherwise, environment variable PASSWD - that is set by contents of ~/.w3m/smb + Password can be passed to smbclient: + 1) When the password is set by contents of ~/.w3m/smb and + -A option available, `smbclient -A ~/.w3m/smb' is used. + 2) When the environment variable PASSWD_FILE, it is used. + 3) When the password is set by contents of ~/.w3m/smb, + the password is passed via standrad I/O using + the environment variable PASSWD_FD. google.cgi diff --git a/Bonus/smb.cgi b/Bonus/smb.cgi index 1473d73..32e6d86 100755 --- a/Bonus/smb.cgi +++ b/Bonus/smb.cgi @@ -9,9 +9,17 @@ # # ----- ~/.w3m/smb ----- # workgroup = -# username = -# password = +# [ username = ] +# [ password = ] +# [ password_file = ] # ---------------------- +# --- --- +# +# ----------------------- +# default: +# = $USER +# = $PASSWD (Don't use!) +# = $PASSWD_FILE $DEBUG = 1; @@ -22,18 +30,35 @@ $AUTH_FILE =~ s@^~/@$ENV{"HOME"}/@; $WORKGROUP = "-"; $USER = $ENV{"USER"}; $PASSWD = $ENV{"PASSWD"}; +$PASSWD_FILE = $ENV{"PASSWD_FILE"}; &load_auth_file($AUTH_FILE); $NMBLOOKUP = "nmblookup"; $SMBCLIENT = "smbclient"; @NMBLOOKUP_OPT = ("-T"); @SMBCLIENT_OPT = ("-N"); -$USE_OPT_A = &check_opt_a(); +$USE_OPT_A = defined($PASSWD) && (-f $AUTH_FILE) && &check_opt_a(); if ($USE_OPT_A) { - undef $USER; - undef $PASSWD; push(@SMBCLIENT_OPT, "-A", $AUTH_FILE); +} elsif (-f $PASSWD_FILE) { + $USE_PASSWD_FILE = 1; +} elsif (defined($PASSWD)) { + $USE_PASSWD_FD = 1; + $PASSWD_FD = 0; } +if (defined($PASSWD)) { + $passwd = "*" x 8; +} +$DEBUG && print <) { - /^\s*$header/ && last; - } + if (/^\s*$header/) { $DEBUG && print "DEBUG: $_"; + last; + } + } while (<$F>) { /^\s*$/ && last; $DEBUG && print "DEBUG: $_"; @@ -277,9 +308,18 @@ sub exec_cmd { local($passwd, @cmd) = @_; $ENV{"LC_ALL"} = "C"; - if (!$USE_OPT_A && $passwd) { - $ENV{"USER"} = $USER if $USER; - $ENV{"PASSWD"} = $PASSWD if $PASSWD; + $ENV{"USER"} = $USER; + if ($passwd && !$USE_OPT_A) { + if ($USE_PASSWD_FILE) { + $ENV{"PASSWD_FILE"} = $PASSWD_FILE; + } elsif ($USE_PASSWD_FD) { + $ENV{"PASSWD_FD"} = $PASSWD_FD; + if (open(W, "|-")) { + print W $PASSWD; + close(W); + exit; + } + } } open(STDERR, ">/dev/null"); exec @cmd; @@ -287,8 +327,15 @@ sub exec_cmd { } sub print_form { + local($_) = @_; + local($q) = &html_quote($_); + $_ = &file_encode($_); + print < +Content-Type: text/html + +

$q

+
Workgroup User Password
@@ -315,6 +362,8 @@ sub load_auth_file { $USER = $_; } elsif (s/^passw(or)?d\s*=\s*//i) { $PASSWD = $_; + } elsif (s/^passw(or)?d_file\s*=\s*//i) { + $PASSWD_FILE = $_; } } close(F); -- cgit v1.2.3