Score:0

Is there a way to identify what computer created a file on a Samba share (mixed-environment)?

za flag

Am currently working on a small side project app that uses a file watcher to monitor specified folders for changes. One of the more common uses of the app would be a network share, such as a samba share. An example of one of these uses would be:

  • One Windows client
  • One MacOS client
  • One Linux client
  • One Ubuntu server running Samba service

When the Windows client adds a file to the share, only the MacOS client and Linux client are notified. However, the file watchers on each client (including the Windows client) will detect the new file. To be able to prevent the Windows client (the "creator" of the file) from getting the notification, I would need the app to be able to know who made the file.

// some funky pseudocode
func onFileCreated(e) {
    if (e.File.Creator == GetHostName())
        return;

    SendToastNotification(e.File);
}

Currently, each client is signed into the same Samba user, and the Owner attribute displays the Samba user (as it should). I don't really understand the inner workings of Samba, but here are a few approaches I am thinking of:

  • Each client has its own user on the Samba server (would be tedious to add more clients in the future)
  • Each client is responsible for knowing if they have just written a file to the Samba share (would require high-level privileges to access file handlers)
  • When a file is uploaded to the share, somehow the Samba server is able to add an arbitrary custom file attribute denoting the host name of whichever client made the file (best case scenario if possible)

Perhaps there are better options available. Many thanks in advance.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.