cfengine  3.15.4
About: CFEngine is a configuration management system for configuring and maintaining Unix-like computers (using an own high level policy language). Community version.
  Fossies Dox: cfengine-3.15.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

systype.c
Go to the documentation of this file.
1 /*
2  Copyright 2019 Northern.tech AS
3 
4  This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
5 
6  This program is free software; you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by the
8  Free Software Foundation; version 3.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 
19  To the extent this program is licensed as part of the Enterprise
20  versions of CFEngine, the applicable Commercial Open Source License
21  (COSL) may apply to this file if you as a licensee so wish it. See
22  included file COSL.txt.
23 */
24 
25 #include <systype.h>
26 #if defined __FreeBSD__
27 #include <sys/param.h>
28 #endif
29 
30 /* Set in libenv/sysinfo.c::DetectEnvironment (called every time environment
31  reload is performed).
32 
33  Utilized all over the place, usually to look up OS-specific command/option to
34  call external utility
35 */
36 PlatformContext VSYSTEMHARDCLASS; /* GLOBAL_E?, initialized_later */
37 PlatformContext VPSHARDCLASS; /* used to define which ps command to use*/
38 
39 
40 /* Configure system name and system-specific details. */
41 
42 const char *const CLASSTEXT[] =
43 {
44  [PLATFORM_CONTEXT_UNKNOWN] = "<unknown>",
45  [PLATFORM_CONTEXT_OPENVZ] = "virt_host_vz_vzps",
46  [PLATFORM_CONTEXT_HP] = "hpux",
47  [PLATFORM_CONTEXT_AIX] = "aix",
48  [PLATFORM_CONTEXT_LINUX] = "linux",
49  [PLATFORM_CONTEXT_BUSYBOX] = "linux",
50  [PLATFORM_CONTEXT_SOLARIS] = "solaris",
51  [PLATFORM_CONTEXT_SUN_SOLARIS] = "solaris",
52  [PLATFORM_CONTEXT_FREEBSD] = "freebsd",
53  [PLATFORM_CONTEXT_NETBSD] = "netbsd",
54  [PLATFORM_CONTEXT_CRAYOS] = "cray",
55  [PLATFORM_CONTEXT_WINDOWS_NT] = "windows",
56  [PLATFORM_CONTEXT_SYSTEMV] = "unix_sv",
57  [PLATFORM_CONTEXT_OPENBSD] = "openbsd",
58  [PLATFORM_CONTEXT_CFSCO] = "sco",
59  [PLATFORM_CONTEXT_DARWIN] = "darwin",
60  [PLATFORM_CONTEXT_QNX] = "qnx",
61  [PLATFORM_CONTEXT_DRAGONFLY] = "dragonfly",
62  [PLATFORM_CONTEXT_MINGW] = "windows",
63  [PLATFORM_CONTEXT_VMWARE] = "vmware",
64  [PLATFORM_CONTEXT_ANDROID] = "android",
65 };
66 
67 const char *const VPSCOMM[] =
68 {
70  [PLATFORM_CONTEXT_OPENVZ] = "/bin/vzps", /* virt_host_vz_vzps */
71  [PLATFORM_CONTEXT_HP] = "/bin/ps", /* hpux */
72  [PLATFORM_CONTEXT_AIX] = "/bin/ps", /* aix */
73  [PLATFORM_CONTEXT_LINUX] = "/bin/ps", /* linux */
74  [PLATFORM_CONTEXT_BUSYBOX] = "/bin/ps", /* linux */
75  [PLATFORM_CONTEXT_SOLARIS] = "/bin/ps", /* solaris >= 11 */
76  [PLATFORM_CONTEXT_SUN_SOLARIS] = "/bin/ps", /* solaris < 11 */
77  [PLATFORM_CONTEXT_FREEBSD] = "/bin/ps", /* freebsd */
78  [PLATFORM_CONTEXT_NETBSD] = "/bin/ps", /* netbsd */
79  [PLATFORM_CONTEXT_CRAYOS] = "/bin/ps", /* cray */
80  [PLATFORM_CONTEXT_WINDOWS_NT] = "/bin/ps", /* NT - cygnus */
81  [PLATFORM_CONTEXT_SYSTEMV] = "/bin/ps", /* unixware */
82  [PLATFORM_CONTEXT_OPENBSD] = "/bin/ps", /* openbsd */
83  [PLATFORM_CONTEXT_CFSCO] = "/bin/ps", /* sco */
84  [PLATFORM_CONTEXT_DARWIN] = "/bin/ps", /* darwin */
85  [PLATFORM_CONTEXT_QNX] = "/bin/ps", /* qnx */
86  [PLATFORM_CONTEXT_DRAGONFLY] = "/bin/ps", /* dragonfly */
87  [PLATFORM_CONTEXT_MINGW] = "mingw-invalid", /* mingw */
88  [PLATFORM_CONTEXT_VMWARE] = "/bin/ps", /* vmware */
89  [PLATFORM_CONTEXT_ANDROID] = "/system/xbin/busybox ps", /* android */
90 };
91 
92 // linux after rhel 3: ps -eo user,pid,ppid,pgid,%cpu,%mem,vsize,ni,rss,stat,nlwp,stime,time,args
93 // solaris: ps -eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args
94 
95 const char *const VPSOPTS[] =
96 {
98  [PLATFORM_CONTEXT_OPENVZ] = "-E 0 -o user,pid,ppid,pgid,pcpu,pmem,vsz,ni,rss,thcount,stime,time,args", /* virt_host_vz_vzps (with vzps, the -E 0 replace the -e) */
99  [PLATFORM_CONTEXT_HP] = "-ef", /* hpux */
100  [PLATFORM_CONTEXT_AIX] = "-N -eo user,pid,ppid,pgid,pcpu,pmem,vsz,ni,stat,st=STIME,time,args", /* aix */
101  /* Note: keep in sync with GetProcessOptions()'s hack for Linux 2.4 */
102  /* For header text "TTY" specify "tname" (not "tty" which gives header "TT") */
103  [PLATFORM_CONTEXT_LINUX] = "-eo user:30,pid,ppid,pgid,pcpu,pmem,vsz,ni,rss:9,tname,nlwp,stime,etime,time,args",/* linux */
104  [PLATFORM_CONTEXT_BUSYBOX] = "", /* linux / busybox */
105  [PLATFORM_CONTEXT_SOLARIS] = "-eo user,pid,pcpu,pmem,osz,rss,tty,s,stime,time,args", /* solaris >= 11 */
106  [PLATFORM_CONTEXT_SUN_SOLARIS] = "-eo user,pid,pcpu,pmem,osz,rss,tty,s,stime,time,args", /* solaris < 11 */
107 #if __FreeBSD_version >= 903000
108  [PLATFORM_CONTEXT_FREEBSD] = "auxw -J 0", /* freebsd 9.3 and newer */
109 #else
110  [PLATFORM_CONTEXT_FREEBSD] = "auxw", /* freebsd 9.2 and older*/
111 #endif
112  [PLATFORM_CONTEXT_NETBSD] = "-axwwo user,pid,ppid,pgid,pcpu,pmem,vsz,ni,rss,nlwp,start,time,args", /* netbsd */
113  [PLATFORM_CONTEXT_CRAYOS] = "-elyf", /* cray */
114  [PLATFORM_CONTEXT_WINDOWS_NT] = "-aW", /* NT */
115  [PLATFORM_CONTEXT_SYSTEMV] = "-ef", /* Unixware */
116  [PLATFORM_CONTEXT_OPENBSD] = "-axwwo user,pid,ppid,pgid,pcpu,pmem,vsz,ni,rss,start,time,args", /* openbsd */
117  [PLATFORM_CONTEXT_CFSCO] = "-ef", /* sco */
118  [PLATFORM_CONTEXT_DARWIN] = "auxw", /* darwin */
119  [PLATFORM_CONTEXT_QNX] = "-elyf", /* qnx */
120  [PLATFORM_CONTEXT_DRAGONFLY] = "auxw", /* dragonfly */
121  [PLATFORM_CONTEXT_MINGW] = "mingw-invalid", /* mingw */
122  [PLATFORM_CONTEXT_VMWARE] = "?", /* vmware */
123  [PLATFORM_CONTEXT_ANDROID] = "", /* android */
124 };
125 
126 const char *const VFSTAB[] =
127 {
128  [PLATFORM_CONTEXT_UNKNOWN] = "-",
129  [PLATFORM_CONTEXT_OPENVZ] = "/etc/fstab", /* virt_host_vz_vzps */
130  [PLATFORM_CONTEXT_HP] = "/etc/fstab", /* hpux */
131  [PLATFORM_CONTEXT_AIX] = "/etc/filesystems", /* aix */
132  [PLATFORM_CONTEXT_LINUX] = "/etc/fstab", /* linux */
133  [PLATFORM_CONTEXT_BUSYBOX] = "/etc/fstab", /* linux */
134  [PLATFORM_CONTEXT_SOLARIS] = "/etc/vfstab", /* solaris */
135  [PLATFORM_CONTEXT_SUN_SOLARIS] = "/etc/vfstab", /* solaris */
136  [PLATFORM_CONTEXT_FREEBSD] = "/etc/fstab", /* freebsd */
137  [PLATFORM_CONTEXT_NETBSD] = "/etc/fstab", /* netbsd */
138  [PLATFORM_CONTEXT_CRAYOS] = "/etc/fstab", /* cray */
139  [PLATFORM_CONTEXT_WINDOWS_NT] = "/etc/fstab", /* NT */
140  [PLATFORM_CONTEXT_SYSTEMV] = "/etc/vfstab", /* Unixware */
141  [PLATFORM_CONTEXT_OPENBSD] = "/etc/fstab", /* openbsd */
142  [PLATFORM_CONTEXT_CFSCO] = "/etc/default/filesys",/* sco */
143  [PLATFORM_CONTEXT_DARWIN] = "/etc/fstab", /* darwin */
144  [PLATFORM_CONTEXT_QNX] = "/etc/fstab", /* qnx */
145  [PLATFORM_CONTEXT_DRAGONFLY] = "/etc/fstab", /* dragonfly */
146  [PLATFORM_CONTEXT_MINGW] = "", /* mingw */
147  [PLATFORM_CONTEXT_VMWARE] = "/etc/fstab", /* vmware */
148  [PLATFORM_CONTEXT_ANDROID] = "", /* android */
149 };
const char *const VPSCOMM[]
Definition: systype.c:67
const char *const CLASSTEXT[]
Definition: systype.c:42
PlatformContext VPSHARDCLASS
Definition: systype.c:37
const char *const VFSTAB[]
Definition: systype.c:126
PlatformContext VSYSTEMHARDCLASS
Definition: systype.c:36
const char *const VPSOPTS[]
Definition: systype.c:95
PlatformContext
Definition: systype.h:31
@ PLATFORM_CONTEXT_UNKNOWN
Definition: systype.h:32
@ PLATFORM_CONTEXT_NETBSD
Definition: systype.h:41
@ PLATFORM_CONTEXT_OPENVZ
Definition: systype.h:33
@ PLATFORM_CONTEXT_MINGW
Definition: systype.h:50
@ PLATFORM_CONTEXT_AIX
Definition: systype.h:35
@ PLATFORM_CONTEXT_SOLARIS
Definition: systype.h:38
@ PLATFORM_CONTEXT_DRAGONFLY
Definition: systype.h:49
@ PLATFORM_CONTEXT_VMWARE
Definition: systype.h:51
@ PLATFORM_CONTEXT_FREEBSD
Definition: systype.h:40
@ PLATFORM_CONTEXT_HP
Definition: systype.h:34
@ PLATFORM_CONTEXT_QNX
Definition: systype.h:48
@ PLATFORM_CONTEXT_DARWIN
Definition: systype.h:47
@ PLATFORM_CONTEXT_LINUX
Definition: systype.h:36
@ PLATFORM_CONTEXT_OPENBSD
Definition: systype.h:45
@ PLATFORM_CONTEXT_SYSTEMV
Definition: systype.h:44
@ PLATFORM_CONTEXT_ANDROID
Definition: systype.h:52
@ PLATFORM_CONTEXT_CFSCO
Definition: systype.h:46
@ PLATFORM_CONTEXT_BUSYBOX
Definition: systype.h:37
@ PLATFORM_CONTEXT_SUN_SOLARIS
Definition: systype.h:39
@ PLATFORM_CONTEXT_WINDOWS_NT
Definition: systype.h:43
@ PLATFORM_CONTEXT_CRAYOS
Definition: systype.h:42