()
| 1112 | } |
| 1113 | |
| 1114 | func homeDirs() []string { |
| 1115 | dirMap := map[string]struct{}{} |
| 1116 | var done bool |
| 1117 | if fsutil.Exists(sysidentity.PasswdFilePath) { |
| 1118 | info, err := sysidentity.ReadPasswdFile(sysidentity.PasswdFilePath) |
| 1119 | if err != nil { |
| 1120 | log.Debugf("sensor.store.homeDirs: error processing passwd: %v", err) |
| 1121 | } else { |
| 1122 | for _, pr := range info.Records { |
| 1123 | if pr.NoLoginShell || pr.Home == "" { |
| 1124 | continue |
| 1125 | } |
| 1126 | |
| 1127 | dirMap[pr.Home] = struct{}{} |
| 1128 | } |
| 1129 | |
| 1130 | done = true |
| 1131 | } |
| 1132 | } |
| 1133 | |
| 1134 | if !done { |
| 1135 | // hacky way to get the home directories for users... |
| 1136 | rootDir := "/root" |
| 1137 | if !fsutil.DirExists(rootDir) { |
| 1138 | dirMap[rootDir] = struct{}{} |
| 1139 | } |
| 1140 | |
| 1141 | homeBaseDir := "/home" |
| 1142 | hdFiles, err := os.ReadDir(homeBaseDir) |
| 1143 | if err == nil { |
| 1144 | for _, file := range hdFiles { |
| 1145 | fullPath := filepath.Join(homeBaseDir, file.Name()) |
| 1146 | if fsutil.IsDir(fullPath) { |
| 1147 | dirMap[fullPath] = struct{}{} |
| 1148 | } |
| 1149 | } |
| 1150 | } else { |
| 1151 | log.Debugf("sensor.store.homeDirs: error enumerating %s: %v", homeBaseDir, err) |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | var dirList []string |
| 1156 | for dp := range dirMap { |
| 1157 | dirList = append(dirList, dp) |
| 1158 | } |
| 1159 | |
| 1160 | return dirList |
| 1161 | } |
| 1162 | |
| 1163 | func (ref *store) saveSSHClient() { |
| 1164 | if !ref.cmd.IncludeSSHClient { |
no test coverage detected