Commit c1d7ff51 authored by jan.koester's avatar jan.koester
Browse files

test

parent 9f8b3ee6
Loading
Loading
Loading
Loading
+4 −1
Changes for src/files.h: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma once

#include <sys/types.h>

#include <string>
#include <vector>

@@ -50,7 +52,8 @@ struct FileEntry {
    std::string type;   // dir, file, link, other
    long long size = 0;
    long long mtime = 0;
    unsigned uid = 0, gid = 0;
    uid_t uid = 0;
    gid_t gid = 0;
    std::string owner, group;  // names, or the numbers
    unsigned mode = 0;         // permission bits incl. setgid/sticky
};
+5 −4
Changes for src/nfs.cpp: 5 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -190,10 +190,10 @@ bool above(const std::string &dir, const std::string &path) {
    return path.size() > dir.size() && path.compare(0, dir.size(), dir) == 0 && path[dir.size()] == '/';
}

void anonIds(int &uid, int &gid) {
void anonIds(uid_t &uid, gid_t &gid) {
    struct passwd *pw = getpwnam("nobody");
    uid = pw ? (int)pw->pw_uid : 65534;
    gid = pw ? (int)pw->pw_gid : 65534;
    uid = pw ? pw->pw_uid : 65534;
    gid = pw ? pw->pw_gid : 65534;
    endpwent();
}

@@ -320,7 +320,8 @@ void NfsServer::answerExport(const std::vector<std::string> &w, int fd) {
    if (w.size() < 2) return;
    const std::string &ip = w[0], &path = w[1];
    const std::string &root = _cfg.settings.nfsRoot;
    int anonUid, anonGid;
    uid_t anonUid;
    gid_t anonGid;
    anonIds(anonUid, anonGid);

    std::string line = quote(ip) + " " + quote(path) + " " + expiry();