fusioninventory-agent
fusioninventory-agent copied to clipboard
Add configuration option for change path of var directory
Hi, It would be interesting to be able to change the path of the var directory via an option in the configuration file or in the registry.
Hi @ermannog can you give us some cases where such a feature would be really interesting ?
Hi @g-bougard this feature can be interested in portable deployment under Windows OS For security the best practices is deny write on the agent directories, but on the var directory is better that users can be write...
For example: ICACLS %SystemDrive%\fusioninventory-agent /inheritance:d ICACLS%SystemDrive%\fusioninventory-agent /remove:g "NT AUTHORITY\Authenticated Users" ICACLS %SystemDrive%\fusioninventory-agent\var /grant:r "BUILTIN\Users":(OI)(CI)(RX,W,DC) /T
For now I solved using ICACLS, but if is possible redirec the var directory this type of configurations is more easy...
If this is mainly for Portable Deployment case, you can try to fix vardir
in the setup.pm
file under perl\lib
forlder. Of course, this means you will share the same vardir
for every agent using this portable install, so you should not set a shared folder here.
vardir
folder is mainly used to store few agent variables, like next time to contact a target. Maybe such information should be stored in registry on win32 platforms. @guillomovitch what do you think ?
The possibility of being able to modify the variable vardir by means of a registry key it would be perfect. In fact this also allows the centralization of the agent. For example, you could keep the portable agent on a read-only share on the server and clients could run the agent on the share and redirect the var directory to local...
Hello, do you decide if you will develop this future and if so in which release do you plan to insert it?
Thanks!
Hello @g-bougard, in the FusionInventory Agent 2.4.1 you have insert this feature?
I'm using currently 2.4:
fusioninventory-agent.bat --version FusionInventory Agent (2.4) Provided by Fusioninventory Installer built with Appveyor on Fri Dec 29 13:28:19 UTC 2017
Now, you can change vardir, and others, in C:\Program Files\FusionInventory-Agent\perl\lib\setup.pm
In order to use portable version, you can set vardir with variables from user's environmnet such as: USERPROFILE, LOCALAPPDATA, ...
Naturally, you will have to get that variable from environ in runtime... for example:
vardir => $ENV{'LOCALAPPDATA'}.'/var'
,
fusioninventory-agent.bat --setup
libdir: C:\Program Files\FusionInventory-Agent/perl/agent
datadir: C:\Program Files\FusionInventory-Agent/share
vardir: C:\Users\myuser\AppData\Local/var
worked for me... just for this example... of course!
I hope this helps you ;-)
Hi @ermannog no I still didn't, maybe next release. @proyectotau thank you for the clear tips, this is actually the way to do.
HI @proyectotau many thanks for the suggest I will try it in the next days! @g-bougard many thanks also to you for the feedback
Hi @ermannog & @proyectotau
this feature has been added to GLPI Agent with vardir
configuration support if you still need it.
You still can test with GLPI Agent nightly builds.
I did this little modification on the perl/bin/fusioninventory-agent file time ago, and it works perfectly.
To release it on the official release only will need to add the new parameter on the --help exit.
*** fusioninventory-agent 2020-11-26 11:38:02.000000000 +0100
--- fusioninventory-agent-new 2022-05-18 10:21:57.474847900 +0200
*************** GetOptions(
*** 61,66 ****
--- 61,67 ----
'tasks=s',
'timeout=i',
'user|u=s',
+ 'vardir=s',
'version',
'wait|w=s',
# deprecated options
*************** if ($options->{daemon}) {
*** 105,110 ****
--- 106,119 ----
}
}
+ if ($options->{'vardir'}) {
+ our %setup = (
+ datadir => '../../share',
+ vardir => $options->{'vardir'},
+ libdir => '../agent',
+ );
+ }
+
my $agent = $options->{daemon} ?
FusionInventory::Agent::Daemon->new(%setup)
:
Hi @NetVicious
you only cover the fusioninventory-agent
script case and even you're fully overriding %setup
where you only really need to set $setup{vardir}
. It should work in your case but, for example, this won't work in the case of windows service. Glpi-agent solution is more general, feel free to backport ;-)
Yes, you're right. This it's only for the fusioninventory-agent portable I use to do the inventory on all the computers on my company each 15 days within one Active Directory GPO.
My knowledge of all the code of fusioninventory it's very reduced, so I did that little change to get it working for me.