Plan 9 from Bell Labs’s /usr/web/sources/contrib/mospak/abaco-modern/abaco-cookies-enable.patch

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


abaco: enable webfs cookie jar per HTTP fetch

abaco has always mounted webfs (/mnt/web) but never told webfs to
send or accept cookies on a given connection.  webfs has the cookie
machinery built in (webfs/http.c:315 injects Cookie headers when
ctl.sendcookies is set, webfs/http.c:482 parses Set-Cookie when
ctl.acceptcookies is set; the jar is persisted to $home/lib/
webcookies automatically).  The two flags default to 0 on every
new webfs connection, so abaco's fetches were always cookie-less.

Fix: after opening a fresh webfs connection via the clone file in
urls.c:urlopen(), write the two ctl lines to enable cookies for
that connection.  One fprint() call.

RFC relevance: 6265 §5.3 (cookie storage), §5.4 (cookie sending);
webfs implements the full jar, this patch only flips per-connection
sendcookies/acceptcookies flags that default to 0.

--- sys/src/cmd/abaco/urls.c
+++ sys/src/cmd/abaco/urls.c
@@ -89,6 +89,7 @@
 		error("reading clone");

 	buf[n] = '\0';
 	conn = atoi(buf);
+	fprint(cfd, "sendcookies 1\nacceptcookies 1\n");

 	snprint(buf, sizeof(buf), "url %S", u->src.r);
 	if(write(cfd, buf, strlen(buf)) < 0){

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.