Warn if run as root
(cherry picked from commit cfdde38b075775f3218f5b18b17c043855472d19)
Fix use after free: var->toString(i).c_str()
Pointer returned by c_str() is only valid until temporary object, returned by var->toString(i) is not destroyed.
Coverity CID 1034470, 1034472
(cherry picked from commit 8e80edcd5048858e4ea97bf947d1948b2683f657)