Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37405587
en ru br
Репозитории ALT
S:0.3.2-alt3
5.1: 0.3.2-alt1
4.1: 0.3.1-alt1
4.0: 0.3.1-alt1
3.0: 0.1-alt2
www.altlinux.org/Changes

Группа :: Система/Библиотеки
Пакет: setproctitle

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

setproctitle-0.3.1/000075500000000000000000000000001060024160200142215ustar00rootroot00000000000000setproctitle-0.3.1/.gitignore000064400000000000000000000000121060024160200162020ustar00rootroot00000000000000*.o
*.so*
setproctitle-0.3.1/LICENSE000064400000000000000000000002601060024160200152240ustar00rootroot00000000000000setproctitle.3 is under the 3-clause BSD-style license as specified
within the file itself.

The rest of the files in this package are under GNU Lesser General
Public License.
setproctitle-0.3.1/Makefile000064400000000000000000000042111060024160200156570ustar00rootroot00000000000000#
# Copyright (C) 2001-2006 Dmitry V. Levin <ldv@altlinux.org>
#
# Makefile for the setproctitle project.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

PROJECT = setproctitle
VERSION = $(shell sed '/^Version: */!d;s///;q' setproctitle.spec)
MAJOR = 0

SHLIB_NAME = lib$(PROJECT).so
SONAME = $(SHLIB_NAME).$(MAJOR)
SHLIB = $(SHLIB_NAME).$(VERSION)
MAP = $(PROJECT).map

TARGETS = $(SHLIB) $(SONAME) $(SHLIB_NAME)

INSTALL = install
libdir = /usr/lib
includedir = /usr/include
mandir = /usr/share/man
man3dir = $(mandir)/man3
DESTDIR =

WARNINGS = -W -Wall -Waggregate-return -Wcast-align -Wconversion \
-Wdisabled-optimization -Wmissing-declarations \
-Wmissing-format-attribute -Wmissing-noreturn \
-Wmissing-prototypes -Wpointer-arith -Wredundant-decls \
-Wshadow -Wstrict-prototypes -Wwrite-strings
CPPFLAGS = -std=gnu99 $(WARNINGS) -D_GNU_SOURCE
CFLAGS = $(RPM_OPT_FLAGS) -fPIC
LDFLAGS = -shared -nostartfiles -Wl,-soname,$(SONAME),--version-script,$(MAP),-z,defs,-z,now,-stats

all: $(TARGETS)

$(SONAME) $(SHLIB_NAME): $(SHLIB)
ln -sf $< $@

$(SHLIB): $(PROJECT).o $(MAP)
$(LINK.o) $< $(OUTPUT_OPTION)

$(PROJECT).o: $(PROJECT).c setproctitle.h

install:
$(INSTALL) -pD -m755 $(SHLIB) $(DESTDIR)$(libdir)/$(SHLIB)
$(INSTALL) -pD -m644 $(PROJECT).3 $(DESTDIR)$(man3dir)/$(PROJECT).3
$(INSTALL) -pD -m644 $(PROJECT).h $(DESTDIR)$(includedir)/$(PROJECT).h
ln -s $(SHLIB) $(DESTDIR)$(libdir)/$(SONAME)
ln -s $(SHLIB) $(DESTDIR)$(libdir)/$(SHLIB_NAME)

clean:
$(RM) $(TARGETS) core *.o *~
setproctitle-0.3.1/setproctitle.3000064400000000000000000000067771060024160200170470ustar00rootroot00000000000000.\" Copyright (c) 2004-2007 Dmitry V. Levin.
.\" All rights reserved.
.\" Copyright (c) 1994, 1995 Christopher G. Demetriou
.\" All rights reserved.
.\"
.\" This manual page was originally developed for the NetBSD Project by
.\" Christopher G. Demetriou.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd March 20, 2007
.Dt SETPROCTITLE 3
.Os
.Sh NAME
.Nm setproctitle
.Nd set process title
.Sh SYNOPSIS
.In setproctitle.h
.Ft int
.Fn setproctitle "const char *fmt" "..."
.Sh DESCRIPTION
The
.Fn setproctitle
function sets the invoking process's title.
The process title is set to the last component of the program
name, followed by a colon, a single space, and the formatted string specified
by
.Fa fmt .
If
.Fa fmt
is
.Dv NULL ,
the colon and formatted string are omitted.
.Sh EXAMPLES
Set the process title to the program name, with no further information:
.Bd -literal -offset indent
setproctitle(0);
.Ed
.Pp
Set the process title to the program name, an informational string,
and the process ID:
.Bd -literal -offset indent
setproctitle("foo! (%d)", getpid());
.Ed
.Sh SEE ALSO
.Xr ps 1 ,
.Xr w 1 ,
.Xr printf 3
.Sh HISTORY
The
.Fn setproctitle
function first appeared in
.Nx 0.9a .
The
.Fn setproctitle
library first appeared in
.Os ALT GNU/Linux .
.Sh AUTHORS
The
.Nm
library was written for the ALT GNU/Linux by
Dmitry V. Levin.
.br
This manual page was written for the NetBSD Project by
Christopher G. Demetriou.
.Sh CAVEATS
It is important never to pass a string with user-supplied data as a
format without using
.Ql %s .
An attacker can put format specifiers in the string to mangle the stack,
leading to a possible security hole.
This holds true even if the string has been built
.Dq by hand
using a function like
.Fn snprintf ,
as the resulting string may still contain user-supplied conversion specifiers
for later interpolation by
.Fn setproctitle .
.Pp
Always be sure to use the proper secure idiom:
.Bd -literal -offset indent
setproctitle("%s", string);
.Ed
.Pp
The
.Fn setproctitle
function clobbers the argv (array of argument strings passed to the
process). If this data is going to be used after first
.Fn setproctitle
invocation, it should be saved in another memory location.
setproctitle-0.3.1/setproctitle.c000064400000000000000000000067041060024160200171150ustar00rootroot00000000000000
/*
Copyright (C) 2004-2006 Dmitry V. Levin <ldv@altlinux.org>

The setproctitle library interface.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library 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
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>

#include "setproctitle.h"

extern int _init(int argc, char *argv[], char *envp[]);

static char *title_buffer = 0;
static size_t title_buffer_size = 0;
static char *title_progname, *title_progname_full;

int
setproctitle(const char *fmt, ...)
{
if (!title_buffer || !title_buffer_size)
{
errno = ENOMEM;
return -1;
}

memset(title_buffer, '\0', title_buffer_size);

ssize_t written;

if (fmt)
{
ssize_t written2;
va_list ap;

written =
snprintf(title_buffer, title_buffer_size, "%s: ",
title_progname);
if (written < 0 || (size_t) written >= title_buffer_size)
return -1;

va_start(ap, fmt);
written2 =
vsnprintf(title_buffer + written,
title_buffer_size - written, fmt, ap);
va_end(ap);
if (written2 < 0
|| (size_t) written2 >= title_buffer_size - written)
return -1;
} else
{
written =
snprintf(title_buffer, title_buffer_size, "%s",
title_progname);
if (written < 0 || (size_t) written >= title_buffer_size)
return -1;
}

written = strlen(title_buffer);
memset(title_buffer + written, '\0', title_buffer_size - written);

return 0;
}

/*
It has to be _init function, because __attribute__((constructor))
functions gets called without arguments.
*/

int
_init(int argc, char *argv[], char *envp[])
{
char *begin_of_buffer = 0, *end_of_buffer = 0;
int i;

for (i = 0; i < argc; ++i)
{
if (!begin_of_buffer)
begin_of_buffer = argv[i];
if (!end_of_buffer || end_of_buffer + 1 == argv[i])
end_of_buffer = argv[i] + strlen(argv[i]);
}

for (i = 0; envp[i]; ++i)
{
if (!begin_of_buffer)
begin_of_buffer = envp[i];
if (!end_of_buffer || end_of_buffer + 1 == envp[i])
end_of_buffer = envp[i] + strlen(envp[i]);
}

if (!end_of_buffer)
return 0;

char **new_environ = malloc((i + 1) * sizeof(envp[0]));

if (!new_environ)
return 0;

for (i = 0; envp[i]; ++i)
if (!(new_environ[i] = strdup(envp[i])))
goto cleanup_enomem;
new_environ[i] = 0;

if (program_invocation_name)
{
title_progname_full = strdup(program_invocation_name);

if (!title_progname_full)
goto cleanup_enomem;

char *p = strrchr(title_progname_full, '/');

if (p)
title_progname = p + 1;
else
title_progname = title_progname_full;

program_invocation_name = title_progname_full;
program_invocation_short_name = title_progname;
}

environ = new_environ;
title_buffer = begin_of_buffer;
title_buffer_size = end_of_buffer - begin_of_buffer;

return 0;

cleanup_enomem:
for (--i; i >= 0; --i)
free(new_environ[i]);
free(new_environ);
return 0;
}
setproctitle-0.3.1/setproctitle.h000064400000000000000000000017571060024160200171250ustar00rootroot00000000000000/*
Copyright (C) 2004-2006 Dmitry V. Levin <ldv@altlinux.org>

The setproctitle library interface.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library 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
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef SETPROCTITLE_H_
#define SETPROCTITLE_H_

extern int setproctitle (const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));

#endif /* SETPROCTITLE_H_ */
setproctitle-0.3.1/setproctitle.map000064400000000000000000000000511060024160200174350ustar00rootroot00000000000000{
global: setproctitle;
local: *;
};
setproctitle-0.3.1/setproctitle.spec000064400000000000000000000034401060024160200176170ustar00rootroot00000000000000Name: setproctitle
Version: 0.3.1
Release: alt1

Summary: A setproctitle implementation
License: LGPL/BSD-style
Group: System/Libraries
Packager: Dmitry V. Levin <ldv@altlinux.org>

Source: %name-%version.tar

%description
This library provides setproctitle function for setting the invoking
process's title.

%package devel
Summary: Development environment for setproctitle
Group: Development/C
Requires: %name = %version-%release

%description devel
This package contains development files required to build
setproctitle-based software.

%prep
%setup -q

%build
%make_build

%install
make install DESTDIR=%buildroot libdir=%_libdir

%post -p %post_ldconfig
%postun -p %postun_ldconfig

%files
%_libdir/*.so.*
%doc LICENSE

%files devel
%_libdir/*.so
%_includedir/*
%_man3dir/*

%changelog
* Wed Mar 21 2007 Dmitry V. Levin <ldv@altlinux.org> 0.3.1-alt1
- setproctitle.3:
+ Noted that setproctitle() clobbers argv[].
+ Updated authorship and license information.
- Packaged LICENSE file, updated License tag.

* Sun Sep 03 2006 Dmitry V. Levin <ldv@altlinux.org> 0.3-alt1
- setproctitle: Clear the _whole_ title buffer every time.
- Linked the library with -Wl,-z,defs.

* Sat Apr 29 2006 Dmitry V. Levin <ldv@altlinux.org> 0.2-alt1
- Build with _GNU_SOURCE defined, replaced deprecated
__progname and __progname_full symbols with
program_invocation_short_name and program_invocation_name.
- Enabled almost all diagnostics supported by gcc
and fixed all issues found by gcc-3.4.5-alt2.
- Changed linking to use gcc instead of ld.
- Linked the library with -Wl,-z,now.
- Updated FSF postal address.

* Tue May 03 2005 Dmitry V. Levin <ldv@altlinux.org> 0.1-alt2
- Pass libdir to "make install" for better mutlilib support (#6764).

* Sun Jun 06 2004 Dmitry V. Levin <ldv@altlinux.org> 0.1-alt1
- Initial revision.
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin