static int slirp_smb(SlirpState* s, const char *exported_dir,
                     struct in_addr vserver_addr)
{
    static int instance;
    char smb_conf[128];
    char smb_cmdline[128];
    struct passwd *passwd;
    FILE *f;
    passwd = getpwuid(geteuid());
    if (!passwd) {
        error_report("failed to retrieve user name");
    snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d",
             (long)getpid(), instance++);
    if (mkdir(s->smb_dir, 0700) < 0) {
        error_report("could not create samba server dir '%s'", s->smb_dir);
    snprintf(smb_conf, sizeof(smb_conf), "%s/%s", s->smb_dir, "smb.conf");
    f = fopen(smb_conf, "w");
    if (!f) {
        slirp_smb_cleanup(s);
        error_report("could not create samba server configuration file '%s'",
                     smb_conf);
    fprintf(f,
            "[global]\n"
            "private dir=%s\n"
            "socket address=127.0.0.1\n"
            "pid directory=%s\n"
            "lock directory=%s\n"
            "state directory=%s\n"
            "log file=%s/log.smbd\n"
            "smb passwd file=%s/smbpasswd\n"
            "security = share\n"
            "[qemu]\n"
            "path=%s\n"
            "read only=no\n"
            "guest ok=yes\n"
            "force user=%s\n",
            s->smb_dir,
            s->smb_dir,
            s->smb_dir,
            s->smb_dir,
            s->smb_dir,
            s->smb_dir,
            exported_dir,
            passwd->pw_name
            );
    fclose(f);
    snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s",
             CONFIG_SMBD_COMMAND, smb_conf);
    if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) {
        slirp_smb_cleanup(s);
        error_report("conflicting/invalid smbserver address");
    return 0;
static int slirp_smb(SlirpState* s, const char *exported_dir,
                     struct in_addr vserver_addr)
{
    static int instance;
    char smb_conf[128];
    char smb_cmdline[128];
    struct passwd *passwd;
    FILE *f;
    passwd = getpwuid(geteuid());
    if (!passwd) {
        error_report("failed to retrieve user name");
    snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d",
             (long)getpid(), instance++);
    if (mkdir(s->smb_dir, 0700) < 0) {
        error_report("could not create samba server dir '%s'", s->smb_dir);
    snprintf(smb_conf, sizeof(smb_conf), "%s/%s", s->smb_dir, "smb.conf");
    f = fopen(smb_conf, "w");
    if (!f) {
        slirp_smb_cleanup(s);
        error_report("could not create samba server configuration file '%s'",
                     smb_conf);
    fprintf(f,
            "[global]\n"
            "private dir=%s\n"
            "socket address=127.0.0.1\n"
            "pid directory=%s\n"
            "lock directory=%s\n"
            "state directory=%s\n"
            "log file=%s/log.smbd\n"
            "smb passwd file=%s/smbpasswd\n"
            "security = share\n"
            "[qemu]\n"
            "path=%s\n"
            "read only=no\n"
            "guest ok=yes\n"
            "force user=%s\n",
            s->smb_dir,
            s->smb_dir,
            s->smb_dir,
            s->smb_dir,
            s->smb_dir,
            s->smb_dir,
            exported_dir,
            passwd->pw_name
            );
    fclose(f);
    snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s",
             CONFIG_SMBD_COMMAND, smb_conf);
    if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) {
        slirp_smb_cleanup(s);
        error_report("conflicting/invalid smbserver address");
    return 0;
static int FUNC_0(SlirpState* VAR_0, const char *VAR_1,
                     struct in_addr VAR_2)
{
    static int VAR_3;
    char VAR_4[128];
    char VAR_5[128];
    struct VAR_6 *VAR_6;
    FILE *f;
    VAR_6 = getpwuid(geteuid());
    if (!VAR_6) {
        error_report("failed to retrieve user name");
    snprintf(VAR_0->smb_dir, sizeof(VAR_0->smb_dir), "/tmp/qemu-smb.%ld-%d",
             (long)getpid(), VAR_3++);
    if (mkdir(VAR_0->smb_dir, 0700) < 0) {
        error_report("could not create samba server dir '%VAR_0'", VAR_0->smb_dir);
    snprintf(VAR_4, sizeof(VAR_4), "%VAR_0/%VAR_0", VAR_0->smb_dir, "smb.conf");
    f = fopen(VAR_4, "w");
    if (!f) {
        slirp_smb_cleanup(VAR_0);
        error_report("could not create samba server configuration file '%VAR_0'",
                     VAR_4);
    fprintf(f,
            "[global]\n"
            "private dir=%VAR_0\n"
            "socket address=127.0.0.1\n"
            "pid directory=%VAR_0\n"
            "lock directory=%VAR_0\n"
            "state directory=%VAR_0\n"
            "log file=%VAR_0/log.smbd\n"
            "smb VAR_6 file=%VAR_0/smbpasswd\n"
            "security = share\n"
            "[qemu]\n"
            "path=%VAR_0\n"
            "read only=no\n"
            "guest ok=yes\n"
            "force user=%VAR_0\n",
            VAR_0->smb_dir,
            VAR_0->smb_dir,
            VAR_0->smb_dir,
            VAR_0->smb_dir,
            VAR_0->smb_dir,
            VAR_0->smb_dir,
            VAR_1,
            VAR_6->pw_name
            );
    fclose(f);
    snprintf(VAR_5, sizeof(VAR_5), "%VAR_0 -VAR_0 %VAR_0",
             CONFIG_SMBD_COMMAND, VAR_4);
    if (slirp_add_exec(VAR_0->slirp, 0, VAR_5, &VAR_2, 139) < 0) {
        slirp_smb_cleanup(VAR_0);
        error_report("conflicting/invalid smbserver address");
    return 0;
static int FUNC_0(SlirpState* VAR_0, const char *VAR_1,
struct in_addr VAR_2)
{ static int VAR_3; char VAR_4[128]; char VAR_5[128]; struct VAR_6 *VAR_6; FILE *f; VAR_6 = getpwuid(geteuid()); if (!VAR_6) { error_report("failed to retrieve user name"); snprintf(VAR_0->smb_dir, sizeof(VAR_0->smb_dir), "/tmp/qemu-smb.%ld-%d",
(long)getpid(), VAR_3++); if (mkdir(VAR_0->smb_dir, 0700) < 0) { error_report("could not create samba server dir '%VAR_0'", VAR_0->smb_dir); snprintf(VAR_4, sizeof(VAR_4), "%VAR_0/%VAR_0", VAR_0->smb_dir, "smb.conf"); f = fopen(VAR_4, "w"); if (!f) { slirp_smb_cleanup(VAR_0); error_report("could not create samba server configuration file '%VAR_0'",
VAR_4); fprintf(f,
"[global]\n"
"private dir=%VAR_0\n"
"socket address=127.0.0.1\n"
"pid directory=%VAR_0\n"
"lock directory=%VAR_0\n"
"state directory=%VAR_0\n"
"log file=%VAR_0/log.smbd\n"
"smb VAR_6 file=%VAR_0/smbpasswd\n"
"security = share\n"
"[qemu]\n"
"path=%VAR_0\n"
"read only=no\n"
"guest ok=yes\n"
"force user=%VAR_0\n",
VAR_0->smb_dir,
VAR_0->smb_dir,
VAR_0->smb_dir,
VAR_0->smb_dir,
VAR_0->smb_dir,
VAR_0->smb_dir,
VAR_1,
VAR_6->pw_name
); fclose(f); snprintf(VAR_5, sizeof(VAR_5), "%VAR_0 -VAR_0 %VAR_0",
CONFIG_SMBD_COMMAND, VAR_4); if (slirp_add_exec(VAR_0->slirp, 0, VAR_5, &VAR_2, 139) < 0) { slirp_smb_cleanup(VAR_0); error_report("conflicting/invalid smbserver address"); return 0;