Thank you Gilles for you answer. Unfortunately getpwuid and getpwnam returned "nil"values, equivalent to the null de lua.
The solution I have developed allows me to run lsyncd in a multi-user and multi-device environment with synchronization with active directory, so that I can save the firefox markers, google chrome, svn settings, filezilla, history... in the active directory and recover them on any computer for any user. This is complicated by the problem of compatibility with symbolic links between the samba dialect, cifs, which uses active directory and linux.
My solution is as follows:(just for Firefox by saving space but can be extended to any software or folder. config.)
1- I install lsyncd and add that scrip in /etc/lsyncd/lsyncd.conf.lua
(The script looks for the home of the user who has just logged on to the /tmp/home file and uses it to create the url with the source and target to synchronize.)
function file_exists(file)
local f = io.open(file, "rb")
if f then f:close() end
return f ~= nil
end
-- get all lines from a file, returns an empty
-- list/table if the file does not exist
function lines_from(file)
if not file_exists(file) then return {} end
lines = {}
for line in io.lines(file) do
lines[#lines + 1] = line
end
return lines
end
-- tests the functions above
local file = '/tmp/lua'
local lines = lines_from(file)
-- print all line numbers and their contents
for k,v in pairs(lines) do
print('line[' .. k .. ']', v)
end
--save line 1 in home
home = lines[1]
settings{
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
}
sync{
default.rsync,
-- Add home to url of the source
source = home.."/.mozilla/firefox/",
--Add home to url of the target
target = home.."/box/.mozilla/firefox/",
delay = 1,
rsync={
perms = true,
owner = true,
},
}
2- With visudo I allow the users I want, in my case all of them, to run lsyncd without password with sudo command:
ALL ALL=NOPASSWD:SETENV: /usr/sbin/service lsyncd *
3- I add the following lines in /etc/profile file
//Delete .mozilla in user's local home in start
rm -Rf $HOME/.mozilla
#mkdir -p $HOME/box/.mozilla/Firefox
//Box is the folder shared with the server
mkdir -p $HOME/box/.config
rm -rf $HOME/box/.config/caja
//2> /dev/null prevents an error due to any other cause from being shown to the user and prevents the user from starting up.
cp -rf $HOME/box/.mozilla $HOME/ 2> /dev/null
cp -rf $HOME/box/.config $HOME/ 2> /dev/null
cp -rf $HOME/box/.subversion $HOME/ 2> /dev/null
echo $HOME >> /tmp/lua;
sudo service lsyncd restart; rm -r /tmp/lua