Can run GAM on command line Centos8 but cannot execute with PHP

33 views
Skip to first unread message

Kriyar EL

unread,
Oct 14, 2021, 4:55:34 AM10/14/21
to GAM for Google Workspace
Dear all,

I have one issue regarding to GAM. I have installed GAM successfully on Centos 8 and I can run gam info user via command line, then get output as expected. However, on my web application with PHP, I use function exec('gam info user ...'), there is no output. Anything wrong? I use Apache as webserver and also granted GAM directory owned by apache. Anything missing from my side?

Appreciate for your help!

Ross Scroggs

unread,
Oct 14, 2021, 11:28:46 AM10/14/21
to google-ap...@googlegroups.com
Kriyar,

Show the full PHP exec command. Are you including the output argument?

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/c80d5eaf-d0b7-40d7-8fc0-e35feaf06f32n%40googlegroups.com.


--

Maj Marshall Giguere

unread,
Oct 14, 2021, 6:06:57 PM10/14/21
to google-ap...@googlegroups.com
Keep in mind that when running on a webserver you are not running as the same user as when you are logged in.
--
Maj Marshall E Giguere
NH Wing Director of IT
Nashua Composite Squadron IT Officer
Civil Air Patrol, U.S. Air Force Auxiliary




Volunteers serving America's communities, saving lives, and shaping futures.


Eric White

unread,
Oct 14, 2021, 7:49:58 PM10/14/21
to GAM for Google Workspace
yes agreed,  so you need to check your environment references to config.

what .gam is referenced?  and where the .gam config is pointing.

cheers.

Maj Marshall Giguere

unread,
Oct 14, 2021, 9:17:34 PM10/14/21
to google-ap...@googlegroups.com
The .gam directory and all the files within it: gam.cfg, client_secrets.json, oauth2.txt must be world readable in order for the webserver to access them.  Not my idea of secure.  Gam is intended as an administrative tool to be run from the cmd line by an admin.  I would be very hesitant to even slightly expose it via a public webserver. Others may disagree.

--
Maj Marshall E Giguere
NH Wing Director of IT
Nashua Composite Squadron IT Officer
Civil Air Patrol, U.S. Air Force Auxiliary




Volunteers serving America's communities, saving lives, and shaping futures.

Eric White

unread,
Oct 14, 2021, 9:23:12 PM10/14/21
to GAM for Google Workspace
giving full admin rights for your Google workspace environment to a php script in a webserver.  On a 1 - 10 security risk scale, it is at least 11!!!

Maj Marshall Giguere

unread,
Oct 14, 2021, 9:34:08 PM10/14/21
to google-ap...@googlegroups.com
Very much in agreement on that point.
I keep  gam  under very tight control and even with that I'm paranoid.

Maj Marshall E Giguere
NH Wing Director of IT
Nashua Composite Squadron IT Officer
Civil Air Patrol, U.S. Air Force Auxiliary




Volunteers serving America's communities, saving lives, and shaping futures.

Kriyar EL

unread,
Oct 14, 2021, 10:52:22 PM10/14/21
to GAM for Google Workspace
Actually, the code was working for almost 1 year, but it just recently stop working. I'm struggling to find out why this happen? I have reinstall GAM, still the same problem.

Kriyar EL

unread,
Oct 14, 2021, 10:55:04 PM10/14/21
to GAM for Google Workspace
I have granted permission and set GAM directly owned by Apache. Actually, the code was working almost 1 year, but recently just stopped working. I have tried several options including reinstall GAM, but the same error. I can run command, working fine, but not working with PHP exec function as I mentioned on the post.

Kriyar EL

unread,
Oct 14, 2021, 10:58:36 PM10/14/21
to GAM for Google Workspace
Yes, I double for configuration and point the GAM. Actually, the code was working almost 1 year, but recently just stopped working. I have tried several options including reinstall GAM, but the same error. I can run command, working fine, but not working with PHP exec function as I mentioned on the post. 

I'm still struggling to figure out now, it's urgent too as my institution is now registering new staff and students, we need to generate email for them automatically with that PHP function, but now it's not working!


Kriyar EL

unread,
Oct 14, 2021, 11:14:18 PM10/14/21
to GAM for Google Workspace
I set owner by apache and grant permission for it too. I was working for almost 1 year, but it suddenly stopped working now. 
I have reinstalled GAM and reconfigure, it still the same issue with PHP exec function, only work with terminal command line.

Samuel

unread,
Oct 15, 2021, 1:32:11 AM10/15/21
to GAM for Google Workspace
what is the error message given by php ?

exec("<path to python> <path to gam> version 2>&1",$output,$code);
var_dump($output);
echo $code;

Kriyar EL

unread,
Oct 15, 2021, 3:24:38 AM10/15/21
to GAM for Google Workspace
Thank you @Samuel for pointing the php code, I got output permission denied when execute the code. Now I moved Gam from root directory (which was set owner apache too) to usr/local/bin, then it works.


Thank you everyone for contributions.  Appreciate your help!

Reply all
Reply to author
Forward
0 new messages