File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -1356,19 +1356,23 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size)
13561356 char * dbus_etc = "/etc/machine-id" ;
13571357
13581358 /* dbus */
1359- ret = machine_id_read_and_sanitize (dbus_var , & id , & bytes );
1360- if (ret == 0 ) {
1361- * out_id = id ;
1362- * out_size = bytes ;
1363- return 0 ;
1359+ if (access (dbus_var , F_OK ) == 0 ) { /* check if the file exists first */
1360+ ret = machine_id_read_and_sanitize (dbus_var , & id , & bytes );
1361+ if (ret == 0 ) {
1362+ * out_id = id ;
1363+ * out_size = bytes ;
1364+ return 0 ;
1365+ }
13641366 }
13651367
13661368 /* etc */
1367- ret = machine_id_read_and_sanitize (dbus_etc , & id , & bytes );
1368- if (ret == 0 ) {
1369- * out_id = id ;
1370- * out_size = bytes ;
1371- return 0 ;
1369+ if (access (dbus_etc , F_OK ) == 0 ) { /* check if the file exists first */
1370+ ret = machine_id_read_and_sanitize (dbus_etc , & id , & bytes );
1371+ if (ret == 0 ) {
1372+ * out_id = id ;
1373+ * out_size = bytes ;
1374+ return 0 ;
1375+ }
13721376 }
13731377#elif defined(__FreeBSD__ ) || defined(__NetBSD__ ) || \
13741378 defined(__OpenBSD__ ) || defined(__DragonFly__ )
You can’t perform that action at this time.
0 commit comments