Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions doc/todos.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,32 @@ into the httpd distribution zip at `make dist` time.
- [ ] Document FTP daemon configuration and capabilities
- [ ] Document console commands (`/F HTTPD,...`) with examples

## UFS / UFSD Integration

- [ ] **Replace `httpd->ufssys` with `int httpd->ufs_enabled`**
The UFSSYS handle from `ufs_sys_new()` is a stub — a `calloc` +
eyecatcher used purely as a boolean "UFS is available" flag.
Replace with a plain `int ufs_enabled` in the HTTPD struct and
change `ftpd->sys` to `int ftpd->ufs_enabled` accordingly.
All checks like `if (httpd->ufssys)` become `if (httpd->ufs_enabled)`.
Priority: none — purely cosmetic cleanup.

- [ ] **Memory leak in `ufs_sys_term()`**
`ufs_sys_new()` allocates a UFSSYS via `calloc()`, but
`ufs_sys_term()` is a no-op and never frees it. Either
`ufs_sys_term()` should accept a `UFSSYS**` and free it, or
the caller (`terminate()` in httpd.c) should `free()` the handle
after `ufs_sys_term()`. Not critical at STC shutdown (address space
goes away), but should be fixed for correctness.

- [ ] **Per-connection UFSD sessions instead of global session**
Currently HTTPD opens one server-level UFS session (`httpd->ufs`)
at startup, and each HTTP client gets its own session via `ufsnew()`
in `socket_thread()`. Evaluate whether per-connection sessions are
worth the overhead vs. sharing the server session with per-request
`ufs_setuser()` calls for identity switching. Consider implications
for concurrent access, permission checks, and session state (cwd).

## Future Work

- [ ] Hot-reload for CGI modules (currently requires STC restart)
Expand Down
2 changes: 1 addition & 1 deletion mbt
4 changes: 4 additions & 0 deletions src/ftpdpass.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ ftpdpass(FTPC *ftpc)
ftpc->flags = 0;

if (ftpc->ufs) {
char group[9];
/* wtof("%s setting acee %08X", __func__, ftpc->acee); */
ufs_set_acee(ftpc->ufs, ftpc->acee);
memcpyp(group, sizeof(group),
&acee->aceegrp[1], acee->aceegrp[0], 0);
ufs_setuser(ftpc->ufs, ftpc->cwd, group);
/* try to change dir to user name */
/* wtof("%s ufs_chgdir(%s)", __func__, ftpc->cwd); */
if (ufs_chgdir(ftpc->ufs, ftpc->cwd)!=0) {
Expand Down
3 changes: 2 additions & 1 deletion src/ftpfopen.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ ftp_ufs_open(FTPC *ftpc, const char *fn, const char *fm, void **ret)
ftpc->fflags = FTPC_FFLAG_UFS; /* fp is a UFS file */
}
else {
wtof("ftpfopen: ufs_fopen(\"%s\",\"%s\") failed", fn, fm);
wtof("ftpfopen: ufs_fopen(\"%s\",\"%s\") failed rc=%d",
fn, fm, ufs_last_rc(ftpc->ufs));
}

quit:
Expand Down
4 changes: 4 additions & 0 deletions src/httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ terminate(void)
array_free(&httpd->httpcgi);
}

if (httpd->ufs) {
ufsfree(&httpd->ufs);
}

if (httpd->ufssys) {
wtof("HTTPD047I Terminating File System");
ufs_sys_term();
Expand Down
Loading