Source
if (1 == invalid_user) /* handle 0 for non-existent user after all parameters have been parsed and validated */
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
static kvm_t *kd = NULL;
static char *proc_argv(pid_t pid)
{
size_t sz = 0;
int mib[4], ret;
int i, len;
static char *argv = NULL;
static size_t argv_alloc = 0;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC_ARGS;
mib[2] = (int)pid;
mib[3] = KERN_PROC_ARGV;
if (0 != sysctl(mib, 4, NULL, &sz, NULL, 0))
return NULL;
if (argv_alloc < sz)
{
argv_alloc = sz;
if (NULL == argv)
argv = zbx_malloc(argv, argv_alloc);
else
argv = zbx_realloc(argv, argv_alloc);
}
sz = argv_alloc;
if (0 != sysctl(mib, 4, argv, &sz, NULL, 0))
return NULL;
for (i = 0; i < (int)(sz - 1); i++ )
if (argv[i] == '\0')
argv[i] = ' ';
return argv;
}