ttt

getttyent

cadaverで環境変数http_proxyで「http://USER:PASS@hogehoge」を使わせる

2014-11-15 23:59:59 | デジタル・インターネット

cadaverという、コマンドラインで動くWebDAVクライアントソフトがあって、たまに使っています。

cadaverは、一応、認証付きのHTTP proxyも通るのですが、毎回、「Authentication required for ほげほげ」と聞かれるのでうざったい。

どこかで、ユーザー名とパスワードを保存することはできないのだろうか?

ということでソースコードを眺めてみる。

ENABLE_NETRCというマクロがあって、もしかして、$HOME/.netrcを使ってくれるのかな???と思うところもあったのですが、結局よくわからず、環境変数http_proxyで「http://USER:PASS@hogehoge」を無理矢理使わせるように改造。

環境変数にパスワードを保存しておくって、いったい何を考えているんですかね、というセキュリティ面の問題はさておき・・・

たしか、supply_creds_proxy()のところだったかな。

--- cadaver.c.ORG    2008-10-29 18:35:33.000000000 +0900
+++ cadaver.c    2014-09-12 14:21:12.000000000 +0900
@@ -1156,7 +1156,26 @@
 {
     if (attempt > 1)
     return -1;
-
+    {
+    char* http_proxy = getenv("http_proxy");
+    if (http_proxy != NULL ) {
+        char* s0 = strstr( http_proxy, "http://");
+        if ( s0 != NULL ) {
+        char* s1 = s0 + 7;
+        char* s2 = strchr( s1, ':' );
+        if ( s2 != NULL ) {
+            char* s3 = strchr( s2, '@' );
+            if ( s3 != NULL ) {
+            *s2 = '\0';
+            *s3 = '\0';
+            ne_strnzcpy(username, s1, NE_ABUFSIZ);
+            ne_strnzcpy(password, s2+1, NE_ABUFSIZ);
+            return 0;
+            }
+        }
+        }
+    }
+    }
     return supply_creds(
     _("Authentication required for %s on proxy server `%s':\n"), realm,
     proxy_hostname, username, password);

うーん。gooブログって、ファイルのアップロード、できないのですか?

gooブログになって、今までできていたことができなくなった、というのがいくつかあって、すっげー不満がたまっています