fusioninventory-agent icon indicating copy to clipboard operation
fusioninventory-agent copied to clipboard

Add configuration option for change path of var directory

Open ermannog opened this issue 7 years ago • 13 comments

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.

ermannog avatar Jan 30 '18 21:01 ermannog

Hi @ermannog can you give us some cases where such a feature would be really interesting ?

g-bougard avatar Jan 31 '18 15:01 g-bougard

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...

ermannog avatar Jan 31 '18 15:01 ermannog

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 ?

g-bougard avatar Feb 01 '18 12:02 g-bougard

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...

ermannog avatar Feb 01 '18 14:02 ermannog

Hello, do you decide if you will develop this future and if so in which release do you plan to insert it?

Thanks!

ermannog avatar May 09 '18 09:05 ermannog

Hello @g-bougard, in the FusionInventory Agent 2.4.1 you have insert this feature?

ermannog avatar Jul 18 '18 08:07 ermannog

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 ;-)

proyectotau avatar Aug 06 '18 11:08 proyectotau

Hi @ermannog no I still didn't, maybe next release. @proyectotau thank you for the clear tips, this is actually the way to do.

g-bougard avatar Aug 07 '18 07:08 g-bougard

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

ermannog avatar Aug 07 '18 07:08 ermannog

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.

g-bougard avatar Jul 01 '21 09:07 g-bougard

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)
      :

NetVicious avatar May 18 '22 08:05 NetVicious

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 ;-)

g-bougard avatar May 18 '22 08:05 g-bougard

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.

NetVicious avatar May 18 '22 09:05 NetVicious