Changeset 857


Ignore:
Timestamp:
Jan 25, 2008 9:00:53 AM (16 years ago)
Author:
dkearney
Message:

added fix for case when USER and HOST env vars do not exist.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/RpLibrary.cc

    r808 r857  
    22102210    std::string timestamp = "";
    22112211    std::string username = "";
     2212    std::string hostname = "";
     2213    char *user = NULL;
     2214    char *host = NULL;
    22122215
    22132216    if (this->root) {
     
    22332236        // how to retrieve username on win32 environment.
    22342237        username = "";
     2238        hostname = "";
    22352239#else
    22362240        timestamp.append(timeinfo->tm_zone);
    2237         username = std::string(getenv("USER"));
     2241        user = getenv("USER");
     2242        if (user != NULL) {
     2243            username = std::string(user);
     2244        }
     2245        host = getenv("HOST");
     2246        if (host != NULL) {
     2247            hostname = std::string(host);
     2248        }
    22382249#endif
    22392250
     
    22422253        put("output.status",exitStatus);
    22432254        put("output.user",username);
     2255        put("output.host",hostname);
    22442256
    22452257        if ( file.is_open() ) {
Note: See TracChangeset for help on using the changeset viewer.