32 #include <sys/types.h>
41 #ifdef RDK_LOGGER_ENABLED
43 int b_rdk_logger_enabled = 0;
45 void logCallback(
const char *buff)
53 #ifdef ENABLE_SD_NOTIFY
54 #include <systemd/sd-daemon.h>
57 #define RFC_BUFFER_SIZE 100
58 int get_irmgr_RFC_config()
61 const char * cmd =
"tr181Set -g Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.XRRemoteAsLinuxDevice.Enable 2>&1 1>/dev/null";
63 printf(
"%s: getting RFC config using command \"%s\"\n", __FUNCTION__, cmd);
64 FILE * pipe = popen(cmd,
"r");
67 char buffer[RFC_BUFFER_SIZE];
68 if(NULL == fgets(buffer, RFC_BUFFER_SIZE, pipe))
70 printf(
"%s: could not parse output of command <%s>.\n", __FUNCTION__, cmd);
74 printf(
"%s: read output \"%s\"\n", __FUNCTION__, buffer);
75 if(0 == strncasecmp(buffer,
"true", 4))
81 printf(
"%s: the feature is %s.\n", __FUNCTION__, (1 == is_enabled?
"enabled" :
"disabled"));
86 static bool drop_root()
88 bool ret =
false,retval =
false;
89 cap_user appcaps = {{0, 0, 0,
'\0', 0, 0, 0,
'\0'}};
90 ret = isBlocklisted();
93 LOG(
"NonRoot feature is disabled\n");
97 LOG(
"NonRoot feature is enabled\n");
99 appcaps.user_name = NULL;
100 if(init_capability() != NULL) {
101 if(drop_root_caps(&appcaps) != -1) {
102 if(update_process_caps(&appcaps) != -1) {
103 read_capability(&appcaps);
113 int main(
int argc,
char *argv[])
115 const char* debugConfigFile = NULL;
120 if(strcmp(argv[itr],
"--debugconfig")==0)
125 debugConfigFile = argv[itr];
135 #ifdef RDK_LOGGER_ENABLED
138 IARM_Bus_RegisterForLog(logCallback);
143 LOG(
"drop_root function failed!\n");
147 int inputEnabled = get_irmgr_RFC_config();
148 if(0 == inputEnabled)
152 inputEnabled = (access(
"/opt/remote_input_enable", F_OK) == 0);
154 #ifdef ENABLE_LINUX_REMOTE_KEYS
156 printf(
"%s: Linux key proceesing enabbled default for RNE build\n",__FUNCTION__);
164 #ifdef ENABLE_SD_NOTIFY
165 sd_notifyf(0,
"READY=1\n"
166 "STATUS=IRMgr is Successfully Initialized\n"
167 "MAINPID=%lu", (
unsigned long) getpid());
171 #define xstr(s) str(s)