mcde_sys_net_browse lists the computers that announce SMB, AFP, NFS, SSH or just themselves by DNS-SD: on NetBSD through mdnsd with dns_sd.h from base (DNSServiceBrowse per type, DNSServiceResolve per service, select until the time is up; docs/reference/dns-sd.txt), on Linux with avahi-browse -atrpk (its \DDD escapes decoded). mcde_sys_net_shares lists NFS exports (showmount -e) and SMB shares (smbclient -g -N -L); mcde_sys_net_mount connects sftp:// (sshfs, a password on its standard input), nfs:// (mount_nfs / mount.nfs) and afp:// (afpfs-ng's mount_afp) to a folder; mcde_sys_net_unmount (fusermount -u, else umount). Host and user names are checked before they reach a command line. mcde_sys_capture_limited ends a child after a time: showmount waited minutes for an rpcbind that was not there (measured in the build VM); the share lists wait 8 seconds. Measured: on the Linux host 4 computers with their services (KITT, N95 with SMB; two laptops with SMB and SSH), the local SMB share and NFS export listed, a host name with ';' refused. In the build VM: it builds with -ldns_sd; without mdnsd a clear message; with mdnsd started the browse ran and found none (qemu's user network carries no multicast); showmount gave up after 8 s. Mounting is not measured yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.9 KiB
C
64 lines
2.9 KiB
C
/*
|
|
* private.h -- MCDE: what common.c and the backends of McdeSys share
|
|
*
|
|
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
|
|
*/
|
|
|
|
#ifndef _McdeSys_private_h
|
|
#define _McdeSys_private_h
|
|
|
|
#include <stddef.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <Mcde/McdeSys.h>
|
|
|
|
/* the failure STATUS with its sentence for the user; returns STATUS */
|
|
int mcde_sys_fail(int status, const char *fmt, ...);
|
|
/* run ARGV (an absolute path first) and wait; MCDE_SYS_OK on exit status 0 */
|
|
int mcde_sys_run(char *const argv[]);
|
|
/* run ARGV and put what it prints (stdout, at most LEN-1 bytes) into BUF */
|
|
int mcde_sys_capture(char *const argv[], char *buf, size_t len);
|
|
/* the first of PATHS (NULL-terminated) that is an executable file, or NULL */
|
|
const char *mcde_sys_which(const char *const *paths);
|
|
/* the same, ending the child after SECONDS (tools that ask the network) */
|
|
int mcde_sys_capture_limited(char *const argv[], char *buf, size_t len,
|
|
int seconds);
|
|
/* run ARGV and write INPUT to its standard input (for chpasswd(8)) */
|
|
int mcde_sys_run_input(char *const argv[], const char *input);
|
|
/* the value after KEY on the first line of FILE that starts with it */
|
|
int mcde_sys_file_value(const char *file, const char *key, char *buf,
|
|
size_t len);
|
|
|
|
/* the backend: the fields of INFO that only the system can tell (common.c
|
|
* has filled in what POSIX gives, the backend may replace it) */
|
|
void mcde_sys_info_backend(McdeSysInfo *info);
|
|
/* the backend: Wi-Fi or not, and the network joined (net.c asks) */
|
|
McdeSysNetKind mcde_sys_if_kind(const char *name, char *ssid, size_t len);
|
|
/* users.c: is LOGIN a member of the administrators' group */
|
|
int mcde_sys_user_is_admin(const char *login);
|
|
/* the backend: the group whose members administer the computer */
|
|
const char *mcde_sys_admin_group(void);
|
|
/* the backend: the shell a new user gets */
|
|
const char *mcde_sys_default_shell(void);
|
|
/* the backend: the arguments of process PID, each ended by a NUL, into BUF;
|
|
* how many bytes, or -1 */
|
|
int mcde_sys_process_args(pid_t pid, char *buf, size_t len);
|
|
/* the backend, for share.c: where the servers keep their configuration
|
|
* (NULL: not on this system), and how an exports(5) line reads */
|
|
const char *mcde_sys_exports_file(void);
|
|
const char *mcde_sys_smb_conf(void);
|
|
const char *mcde_sys_afp_conf(void);
|
|
void mcde_sys_export_line(const char *path, char *buf, size_t len);
|
|
/* the backend: make running servers read their configuration again */
|
|
void mcde_sys_shares_reload(void);
|
|
/* netmount.c: a service of KIND found on HOST (NAME as it calls itself)
|
|
* into HOSTS, merged by host; the new count */
|
|
int mcde_sys_net_add(McdeSysNetHost *hosts, int n, size_t max,
|
|
const char *name, const char *host, int kind);
|
|
/* the backend: the mixer when no sound server runs (sound.c asks) */
|
|
int mcde_sys_mixer_get(int *percent, int *muted);
|
|
int mcde_sys_mixer_set(int percent);
|
|
int mcde_sys_mixer_mute(int muted);
|
|
|
|
#endif /* _McdeSys_private_h */
|