Compare commits

..

12 Commits

Author SHA1 Message Date
Robert Roth
30c771151d Prepared release 2.39.90 2019-02-04 22:27:23 +02:00
Charles Monzat
77912eae1d Update French translation 2018-12-29 14:53:23 +00:00
Robert Roth
b71a5c1404 Merge branch 'wip/lantw/freebsd-laundry-memory-and-zfs-arc' into 'master'
freebsd: Support laundry memory and ZFS ARC

See merge request GNOME/libgtop!3
2018-11-21 06:21:53 +00:00
Balasankar C
8e4c9c197b Update Malayalam translation 2018-10-26 15:13:16 +00:00
Ting-Wei Lan
bb118fa9d6 freebsd: Support laundry memory and ZFS ARC
FreeBSD 11.1 removes cache memory and adds laundry memory. The MIB of
cache memory still exists, but its value is always set to zero.
According to the man page of top(1), the value of laundry memory means
number of dirty pages queued for laundering, suggesting that it should
be added to the 'user' in libgtop because it cannot be freed immediately
without writing out data. Laundry memory was part of inactive memory in
older FreeBSD releases.

FreeBSD systems running on ZFS usually have a large portion of memory
used as ZFS ARC, which has similar purpose to buffer cache of other
filesystems. ZFS ARC can usually be freed quickly when the system needs
more memory, so we don't want to put it in 'user' in libgtop. However,
both buffer cache and ZFS ARC are parts of wired memory, and wired
memory is counted in 'user'. Therefore, we subtract the size of ZFS ARC
from wired memory when calculating 'user' value, making it more useful
to FreeBSD users.

This patch is based on the patch submiited three years ago by
Benoît Dejean <bdejean@gmail.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=748928
https://gitlab.gnome.org/GNOME/libgtop/issues/31
2018-10-25 00:30:12 +08:00
Piotr Drąg
69f7b16421 Update MSGID_BUGS_ADDRESS in po/Makevars 2018-08-16 20:21:24 +02:00
Benoît Dejean
7c811a7826 Fixed 3 old compile warnings. 2018-07-22 12:23:11 +02:00
Mingcong Bai
40144f3908 Update Chinese (China) translation 2018-05-21 14:31:20 +00:00
Daniel Șerbănescu
35a0ba8e27 Update Romanian translation 2018-03-26 20:38:41 +00:00
Benoît Dejean
ec6a87e670 Bump version number and SO libgtop_revision. 2018-03-26 18:28:59 +02:00
Benoît Dejean
e4335d4db2 glibtop_get_proc_map on Linux doesn't need to be SUID.
Revert this proof of concept.
Add C file with comments to document how to make a call SUID.
2018-03-26 18:15:26 +02:00
Benoît Dejean
ec662d01da Make linux build with server.
Add suid infrastructure.
Demo proc_map.
2018-03-26 17:44:43 +02:00
16 changed files with 629 additions and 134 deletions

12
NEWS
View File

@@ -1,3 +1,15 @@
04 February 2019: Overview of changes in 2.39.90
================================================
* Updated translations
* FreeBSD:
- added support for laundry memory
- added support for ZFS ARC
* Fixed compile warnings
* Fix build on FreeBSD and darwin
* Linux:
- get procmap doesn't need suid
11 September 2017: Overview of changes in 2.38.0
================================================

View File

@@ -3,8 +3,8 @@ dnl Configure script for the Gnome library
dnl
m4_define([libgtop_major_version], [2])
m4_define([libgtop_minor_version], [38])
m4_define([libgtop_micro_version], [0])
m4_define([libgtop_minor_version], [39])
m4_define([libgtop_micro_version], [90])
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
dnl increment if the interface has additions, changes, removals.
@@ -12,7 +12,7 @@ m4_define([libgtop_current], [11])
dnl increment any time the source changes; set to
dnl 0 if you increment CURRENT
m4_define([libgtop_revision], [0])
m4_define([libgtop_revision], [1])
dnl increment if any interfaces have been added; set to 0
dnl if any interfaces have been removed. removal has

View File

@@ -33,9 +33,10 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
linux*)
libgtop_sysdeps_dir=linux
libgtop_have_sysinfo=yes
libgtop_need_server=no
libgtop_need_server=yes
libgtop_sysdeps_private_mountlist=yes
libgtop_sysdeps_private_fsusage=yes
libgtop_postinstall='chown root $(bindir)/libgtop_server2 && chmod 4755 $(bindir)/libgtop_server2'
;;
netbsd*|bsdi*)
libgtop_sysdeps_dir=bsd

View File

@@ -18,7 +18,7 @@ XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2
# or entity, or to disclaim their copyright. The empty string stands for
# the public domain; in this case the translators are expected to disclaim
# their copyright.
COPYRIGHT_HOLDER = libgtop contributors
COPYRIGHT_HOLDER = libgtop authors
# This tells whether or not to prepend "GNU " prefix to the package
# name that gets inserted into the header of the $(DOMAIN).pot file.
@@ -41,7 +41,7 @@ PACKAGE_GNU = no
# It can be your email address, or a mailing list address where translators
# can write to without being subscribed, or the URL of a web page through
# which the translators can contact you.
MSGID_BUGS_ADDRESS = https://bugzilla.gnome.org/enter_bug.cgi?product=libgtop&keywords=I18N+L10N&component=general
MSGID_BUGS_ADDRESS = https://gitlab.gnome.org/GNOME/libgtop/issues
# This is the list of locale categories, beyond LC_MESSAGES, for which the
# message catalogs shall be used. It is usually empty.
@@ -51,7 +51,7 @@ EXTRA_LOCALE_CATEGORIES =
# context. Possible values are "yes" and "no". Set this to yes if the
# package uses functions taking also a message context, like pgettext(), or
# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
USE_MSGCTXT = no
USE_MSGCTXT = yes
# These options get passed to msgmerge.
# Useful options are in particular:

View File

@@ -7,21 +7,22 @@
# Christophe Merlet <redfox@redfoxcenter.org>, 2000-2004.
# Benoit Dejean <tazforever@dlfp.org>, 2004.
# Stéphane Raimbault <stephane.raimbault@gmail.com>, 2007.
# Charles Monzat <charles.monzat@numericable.fr>, 2018.
#
msgid ""
msgstr ""
"Project-Id-Version: libgtop 2.9.91\n"
"Report-Msgid-Bugs-To: https://bugzilla.gnome.org/enter_bug.cgi?"
"product=libgtop&keywords=I18N+L10N&component=general\n"
"POT-Creation-Date: 2017-04-07 11:45+0000\n"
"PO-Revision-Date: 2017-08-15 09:18+0200\n"
"Last-Translator: Stéphane Raimbault <stephane.raimbault@gmail.com>\n"
"Language-Team: GNOME French Team <gnomefr@traduc.org>\n"
"Report-Msgid-Bugs-To: https://gitlab.gnome.org/GNOME/libgtop/issues\n"
"POT-Creation-Date: 2018-01-25 10:19+0000\n"
"PO-Revision-Date: 2018-11-19 13:23+0100\n"
"Last-Translator: Charles Monzat <charles.monzat@numericable.fr>\n"
"Language-Team: français <gnomefr@traduc.org>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n>1;\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Gtranslator 3.30.0\n"
#: lib/read.c:49
#, c-format
@@ -89,7 +90,7 @@ msgstr "Instruction illégale"
#: sysdeps/osf1/siglist.c:31 sysdeps/sun4/siglist.c:31
msgid "Trace trap"
msgstr "Point d'arrêt rencontré"
msgstr "Point darrêt rencontré"
#: sysdeps/osf1/siglist.c:32 sysdeps/sun4/siglist.c:32
msgid "Abort"
@@ -117,7 +118,7 @@ msgstr "Violation de segmentation"
#: sysdeps/osf1/siglist.c:38 sysdeps/sun4/siglist.c:38
msgid "Bad argument to system call"
msgstr "Mauvais argument d'appel système"
msgstr "Mauvais argument dappel système"
#: sysdeps/osf1/siglist.c:39 sysdeps/sun4/siglist.c:39
msgid "Broken pipe"
@@ -125,7 +126,7 @@ msgstr "Tube cassé"
#: sysdeps/osf1/siglist.c:40 sysdeps/sun4/siglist.c:40
msgid "Alarm clock"
msgstr "Alarme d'horloge"
msgstr "Alarme dhorloge"
#: sysdeps/osf1/siglist.c:41 sysdeps/sun4/siglist.c:41
msgid "Termination"
@@ -149,7 +150,7 @@ msgstr "Continuer"
#: sysdeps/osf1/siglist.c:46 sysdeps/sun4/siglist.c:46
msgid "Child status has changed"
msgstr "L'état du fils a changé"
msgstr "Létat du fils a changé"
#: sysdeps/osf1/siglist.c:47 sysdeps/sun4/siglist.c:47
msgid "Background read from tty"
@@ -177,7 +178,7 @@ msgstr "Alarme virtuelle"
#: sysdeps/osf1/siglist.c:53 sysdeps/sun4/siglist.c:53
msgid "Profiling alarm clock"
msgstr "Profile de l'alarme"
msgstr "Profil de lalarme"
#: sysdeps/osf1/siglist.c:54 sysdeps/sun4/siglist.c:54
msgid "Window size change"
@@ -185,7 +186,7 @@ msgstr "Redimensionnement de la fenêtre"
#: sysdeps/osf1/siglist.c:55 sysdeps/sun4/siglist.c:55
msgid "Information request"
msgstr "Demande d'information"
msgstr "Demande dinformation"
#: sysdeps/osf1/siglist.c:56 sysdeps/sun4/siglist.c:56
msgid "User defined signal 1"

View File

@@ -7,189 +7,184 @@
msgid ""
msgstr ""
"Project-Id-Version: libgtop.master.ml\n"
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=libgtop&component=general\n"
"POT-Creation-Date: 2009-04-17 10:17+0000\n"
"PO-Revision-Date: 2009-09-12 20:37+0530\n"
"Report-Msgid-Bugs-To: https://gitlab.gnome.org/GNOME/libgtop/issues\n"
"POT-Creation-Date: 2018-01-25 10:19+0000\n"
"PO-Revision-Date: 2018-10-26 19:49+0530\n"
"Last-Translator: \n"
"Language-Team: <en@li.org>\n"
"Language: ml\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.4\n"
"X-Generator: Poedit 2.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"\n"
#: ../lib/read.c:51
#: lib/read.c:49
#, c-format
msgid "read %d byte"
msgid_plural "read %d bytes"
msgstr[0] "%d ബൈറ്റ് വായിക്കുക"
msgstr[1] "%d ബൈറ്റ്സ് വായിക്കുക"
#: ../lib/read_data.c:51
#: lib/read_data.c:49
msgid "read data size"
msgstr "ഡേറ്റായുടെ വലിപ്പം വായിക്കുക"
#: ../lib/read_data.c:70
#: lib/read_data.c:66
#, c-format
msgid "read %lu byte of data"
msgid_plural "read %lu bytes of data"
msgstr[0] "%lu ബൈറ്റ് ഡേറ്റാ വായിക്കുക"
msgstr[1] "%lu ബൈറ്റ്സ് ഡേറ്റാ വായിക്കുക"
#: ../lib/write.c:51
#: lib/write.c:49
#, c-format
msgid "wrote %d byte"
msgid_plural "wrote %d bytes"
msgstr[0] "%d ബൈറ്റ് എഴുതി"
msgstr[1] "%d ബൈറ്റ്സ് എഴുതി"
#: ../src/daemon/gnuserv.c:455
#: src/daemon/gnuserv.c:456
msgid "Enable debugging"
msgstr "ഡീബഗ്ഗിങ് പ്രവര്‍ത്തന സജ്ജമാക്കുക"
#: ../src/daemon/gnuserv.c:457
#: src/daemon/gnuserv.c:458
msgid "Enable verbose output"
msgstr "വര്‍ബറോസ് ഔട്ട് പുട്ട് പ്രവര്‍ത്തന സജ്ജമാക്കുക"
#: ../src/daemon/gnuserv.c:459
msgid "Don't fork into background"
msgstr "പശ്ചാത്തലത്തിലേക്ക് fork ചെയ്യുവാന്‍ പാടില്ല"
#: src/daemon/gnuserv.c:460
msgid "Dont fork into background"
msgstr "പശ്ചാത്തലത്തിലേക്ക് ഫോർക് ചെയ്യുവാന്‍ പാടില്ല"
#: ../src/daemon/gnuserv.c:461
#: src/daemon/gnuserv.c:462
msgid "Invoked from inetd"
msgstr "inetd-ല്‍ നിന്നുമുളള വിളി"
#: ../src/daemon/gnuserv.c:495
#: src/daemon/gnuserv.c:498
#, c-format
#| msgid ""
#| "Error on option %s: %s.\n"
#| "Run '%s --help' to see a full list of available command line options.\n"
msgid "Run '%s --help' to see a full list of available command line options.\n"
msgid "Run “%s --help” to see a full list of available command line options.\n"
msgstr "ലഭ്യമായ കമാന്‍ഡ് ലൈന്‍ ഉപാധികളുടെ മുഴുവന്‍ പട്ടികയ്ക്ക് '%s --help' പ്രവര്‍ത്തിപ്പിക്കുക.\n"
#: ../sysdeps/osf1/siglist.c:27 ../sysdeps/sun4/siglist.c:27
#: sysdeps/osf1/siglist.c:27 sysdeps/sun4/siglist.c:27
msgid "Hangup"
msgstr "അവസാനിപ്പിക്കുക"
#: ../sysdeps/osf1/siglist.c:28 ../sysdeps/sun4/siglist.c:28
#: sysdeps/osf1/siglist.c:28 sysdeps/sun4/siglist.c:28
msgid "Interrupt"
msgstr "ഇന്‍ററപ്റ്റ്"
#: ../sysdeps/osf1/siglist.c:29 ../sysdeps/sun4/siglist.c:29
#: sysdeps/osf1/siglist.c:29 sysdeps/sun4/siglist.c:29
msgid "Quit"
msgstr "പുറത്ത് കടക്കുക"
#: ../sysdeps/osf1/siglist.c:30 ../sysdeps/sun4/siglist.c:30
#: sysdeps/osf1/siglist.c:30 sysdeps/sun4/siglist.c:30
msgid "Illegal instruction"
msgstr "തെറ്റായ നിര്‍ദ്ദേശം"
#: ../sysdeps/osf1/siglist.c:31 ../sysdeps/sun4/siglist.c:31
#: sysdeps/osf1/siglist.c:31 sysdeps/sun4/siglist.c:31
msgid "Trace trap"
msgstr "തടസ്സം കണ്ടുപിടിക്കുക"
#: ../sysdeps/osf1/siglist.c:32 ../sysdeps/sun4/siglist.c:32
#: sysdeps/osf1/siglist.c:32 sysdeps/sun4/siglist.c:32
msgid "Abort"
msgstr "നിര്‍ത്തലാക്കുക"
#: ../sysdeps/osf1/siglist.c:33 ../sysdeps/sun4/siglist.c:33
#: sysdeps/osf1/siglist.c:33 sysdeps/sun4/siglist.c:33
msgid "EMT error"
msgstr "EMT പിശക്"
#: ../sysdeps/osf1/siglist.c:34 ../sysdeps/sun4/siglist.c:34
#: sysdeps/osf1/siglist.c:34 sysdeps/sun4/siglist.c:34
msgid "Floating-point exception"
msgstr "ഫ്ളോട്ടിങ്-പോയിന്‍റ് എക്സെപ്ഷന്‍"
#: ../sysdeps/osf1/siglist.c:35 ../sysdeps/sun4/siglist.c:35
#: sysdeps/osf1/siglist.c:35 sysdeps/sun4/siglist.c:35
msgid "Kill"
msgstr "അവസാനിപ്പിക്കുക"
#: ../sysdeps/osf1/siglist.c:36 ../sysdeps/sun4/siglist.c:36
#: sysdeps/osf1/siglist.c:36 sysdeps/sun4/siglist.c:36
msgid "Bus error"
msgstr "ബസില്‍ പിശക്"
#: ../sysdeps/osf1/siglist.c:37 ../sysdeps/sun4/siglist.c:37
#: sysdeps/osf1/siglist.c:37 sysdeps/sun4/siglist.c:37
msgid "Segmentation violation"
msgstr "സെഗ്മന്‍റേഷനില്‍ തെറ്റ്"
#: ../sysdeps/osf1/siglist.c:38 ../sysdeps/sun4/siglist.c:38
#: sysdeps/osf1/siglist.c:38 sysdeps/sun4/siglist.c:38
msgid "Bad argument to system call"
msgstr "സിസ്റ്റം കോളിലേക്ക് തെറ്റായ ആര്‍ഗ്യുമെന്‍റ്"
#: ../sysdeps/osf1/siglist.c:39 ../sysdeps/sun4/siglist.c:39
#: sysdeps/osf1/siglist.c:39 sysdeps/sun4/siglist.c:39
msgid "Broken pipe"
msgstr "പൊട്ടിയ പൈപ്പ്"
#: ../sysdeps/osf1/siglist.c:40 ../sysdeps/sun4/siglist.c:40
#: sysdeps/osf1/siglist.c:40 sysdeps/sun4/siglist.c:40
msgid "Alarm clock"
msgstr "അലാറം ക്ളോക്ക്"
#: ../sysdeps/osf1/siglist.c:41 ../sysdeps/sun4/siglist.c:41
#: sysdeps/osf1/siglist.c:41 sysdeps/sun4/siglist.c:41
msgid "Termination"
msgstr "അവസാനിപ്പിക്കല്‍"
#: ../sysdeps/osf1/siglist.c:42 ../sysdeps/sun4/siglist.c:42
#: sysdeps/osf1/siglist.c:42 sysdeps/sun4/siglist.c:42
msgid "Urgent condition on socket"
msgstr "സോക്കന്‍റില്‍ ഗുരുതരമായ അവസ്ഥ"
#: ../sysdeps/osf1/siglist.c:43 ../sysdeps/sun4/siglist.c:43
#: sysdeps/osf1/siglist.c:43 sysdeps/sun4/siglist.c:43
msgid "Stop"
msgstr "നിര്‍ത്തുക"
#: ../sysdeps/osf1/siglist.c:44 ../sysdeps/sun4/siglist.c:44
#: sysdeps/osf1/siglist.c:44 sysdeps/sun4/siglist.c:44
msgid "Keyboard stop"
msgstr "കീബോര്‍ഡ് നിര്‍ത്തുക"
#: ../sysdeps/osf1/siglist.c:45 ../sysdeps/sun4/siglist.c:45
#: sysdeps/osf1/siglist.c:45 sysdeps/sun4/siglist.c:45
msgid "Continue"
msgstr "തുടരുക"
#: ../sysdeps/osf1/siglist.c:46 ../sysdeps/sun4/siglist.c:46
#: sysdeps/osf1/siglist.c:46 sysdeps/sun4/siglist.c:46
msgid "Child status has changed"
msgstr "ചൈള്‍ഡിന്‍റെ അവസ്ഥ മാറിയിരിക്കുന്നു"
#: ../sysdeps/osf1/siglist.c:47 ../sysdeps/sun4/siglist.c:47
#: sysdeps/osf1/siglist.c:47 sysdeps/sun4/siglist.c:47
msgid "Background read from tty"
msgstr "tty-ല്‍ നിന്നും പശ്ചാത്തലം വായിക്കുക"
#: ../sysdeps/osf1/siglist.c:48 ../sysdeps/sun4/siglist.c:48
#: sysdeps/osf1/siglist.c:48 sysdeps/sun4/siglist.c:48
msgid "Background write to tty"
msgstr "tty-ലേക്ക് പശ്ചാത്തലം എഴുതുക"
#: ../sysdeps/osf1/siglist.c:49 ../sysdeps/sun4/siglist.c:49
#: sysdeps/osf1/siglist.c:49 sysdeps/sun4/siglist.c:49
msgid "I/O now possible"
msgstr "I/O ഇപ്പോള്‍ സാധ്യമാണ്"
#: ../sysdeps/osf1/siglist.c:50 ../sysdeps/sun4/siglist.c:50
#: sysdeps/osf1/siglist.c:50 sysdeps/sun4/siglist.c:50
msgid "CPU limit exceeded"
msgstr "CPU പരിമിധി കവിഞ്ഞു"
#: ../sysdeps/osf1/siglist.c:51 ../sysdeps/sun4/siglist.c:51
#: sysdeps/osf1/siglist.c:51 sysdeps/sun4/siglist.c:51
msgid "File size limit exceeded"
msgstr "ഫയലിന്‍റെ വലിപ്പ പരിമിധി കവിഞ്ഞു"
#: ../sysdeps/osf1/siglist.c:52 ../sysdeps/sun4/siglist.c:52
#: sysdeps/osf1/siglist.c:52 sysdeps/sun4/siglist.c:52
msgid "Virtual alarm clock"
msgstr "വിര്‍ച്ച്വല്‍ അലാറം ക്ളോക്ക്"
#: ../sysdeps/osf1/siglist.c:53 ../sysdeps/sun4/siglist.c:53
#: sysdeps/osf1/siglist.c:53 sysdeps/sun4/siglist.c:53
msgid "Profiling alarm clock"
msgstr "അലാറം ക്ളോക്ക് പ്രൊഫൈല്‍ ചെയ്യുന്നു"
#: ../sysdeps/osf1/siglist.c:54 ../sysdeps/sun4/siglist.c:54
#: sysdeps/osf1/siglist.c:54 sysdeps/sun4/siglist.c:54
msgid "Window size change"
msgstr "ജീലകത്തിന്‍റെ വലിപ്പത്തലുളള മാറ്റം"
#: ../sysdeps/osf1/siglist.c:55 ../sysdeps/sun4/siglist.c:55
#: sysdeps/osf1/siglist.c:55 sysdeps/sun4/siglist.c:55
msgid "Information request"
msgstr "വിവരങ്ങള്‍ക്കായുളള അഭ്യര്‍ത്ഥന"
#: ../sysdeps/osf1/siglist.c:56 ../sysdeps/sun4/siglist.c:56
#: sysdeps/osf1/siglist.c:56 sysdeps/sun4/siglist.c:56
msgid "User defined signal 1"
msgstr "യൂസര്‍ ഡിഫൈന്‍ഡ് സിഗ്നല്‍ 1"
#: ../sysdeps/osf1/siglist.c:57 ../sysdeps/sun4/siglist.c:57
#: sysdeps/osf1/siglist.c:57 sysdeps/sun4/siglist.c:57
msgid "User defined signal 2"
msgstr "യൂസര്‍ ഡിഫൈന്‍ഡ് സിഗ്നല്‍ 2"

View File

@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: libgtop\n"
"Report-Msgid-Bugs-To: https://gitlab.gnome.org/GNOME/libgtop/issues\n"
"POT-Creation-Date: 2018-03-20 20:09+0000\n"
"POT-Creation-Date: 2018-03-26 20:36+0000\n"
"PO-Revision-Date: 2018-03-25 14:30+0200\n"
"Last-Translator: Daniel Șerbănescu <daniel [at] serbanescu [dot] dk>\n"
"Language-Team: Gnome Romanian Translation Team\n"
@@ -55,7 +55,6 @@ msgid "Enable verbose output"
msgstr "Mesaje de ieșire explicite"
#: src/daemon/gnuserv.c:460
#| msgid "Don't fork into background"
msgid "Dont fork into background"
msgstr "Nu clona în fundal"
@@ -65,8 +64,6 @@ msgstr "Pornit de inetd"
#: src/daemon/gnuserv.c:498
#, c-format
#| msgid ""
#| "Run '%s --help' to see a full list of available command line options.\n"
msgid "Run “%s --help” to see a full list of available command line options.\n"
msgstr "Încercați „%s --help” pentru a vedea o listă completă a opțiunilor.\n"

View File

@@ -1,187 +1,191 @@
# translation of libgtop.po to simplified chinese.
# Copyright (C) 2001,2003 Free Software Foundation, Inc.
# Dillion Chen <dillon.chen@turbolinux.com.cn>, 2003.
# Funda Wang <fundawang@linux.net.cn>, 2004
# Funda Wang <fundawang@linux.net.cn>, 2004.
# Mingcong Bai <jeffbai@aosc.xyz>, 2017.
#
msgid ""
msgstr ""
"Project-Id-Version: libgtop\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-05-14 03:41+0100\n"
"PO-Revision-Date: 2007-09-07 17:29+0800\n"
"Last-Translator: Funda Wang <fundawang@linux.net.cn>\n"
"Report-Msgid-Bugs-To: https://bugzilla.gnome.org/enter_bug.cgi?"
"product=libgtop&keywords=I18N+L10N&component=general\n"
"POT-Creation-Date: 2017-04-07 11:45+0000\n"
"PO-Revision-Date: 2017-06-10 14:27+0800\n"
"Last-Translator: Mingcong Bai <jeffbai@aosc.xyz>\n"
"Language-Team: zh_CN <i18n-translation@lists.linux.net.cn>\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 2.0.2\n"
#: ../lib/read.c:51
#: lib/read.c:49
#, c-format
msgid "read %d byte"
msgid_plural "read %d bytes"
msgstr[0] "读取 %d 字节"
#: ../lib/read_data.c:51
#: lib/read_data.c:49
msgid "read data size"
msgstr "读取数据大小"
#: ../lib/read_data.c:70
#: lib/read_data.c:66
#, c-format
msgid "read %lu byte of data"
msgid_plural "read %lu bytes of data"
msgstr[0] "读取了 %lu 字节数据"
#: ../lib/write.c:51
#: lib/write.c:49
#, c-format
msgid "wrote %d byte"
msgid_plural "wrote %d bytes"
msgstr[0] "写入了 %d 字节"
#: ../src/daemon/gnuserv.c:458
#: src/daemon/gnuserv.c:456
msgid "Enable debugging"
msgstr "允许调试"
#: ../src/daemon/gnuserv.c:460
#: src/daemon/gnuserv.c:458
msgid "Enable verbose output"
msgstr "允许详细输出"
#: ../src/daemon/gnuserv.c:462
msgid "Don't fork into background"
msgstr "不在后台生成子进程"
#: src/daemon/gnuserv.c:460
msgid "Dont fork into background"
msgstr "不在后台生成子进程"
#: ../src/daemon/gnuserv.c:464
#: src/daemon/gnuserv.c:462
msgid "Invoked from inetd"
msgstr "从 inetd 调用"
#: ../src/daemon/gnuserv.c:498
#: src/daemon/gnuserv.c:498
#, c-format
msgid "Run '%s --help' to see a full list of available command line options.\n"
msgstr ""
"运行“%s --help”可查看可用命令行选项的完整列表\n"
msgid ""
"Run “%s --help” to see a full list of available command line "
"options.\n"
msgstr "运行“%s --help”可查看可用命令行选项的完整列表。\n"
#: ../sysdeps/osf1/siglist.c:27 ../sysdeps/sun4/siglist.c:27
#: sysdeps/osf1/siglist.c:27 sysdeps/sun4/siglist.c:27
msgid "Hangup"
msgstr "挂起"
#: ../sysdeps/osf1/siglist.c:28 ../sysdeps/sun4/siglist.c:28
#: sysdeps/osf1/siglist.c:28 sysdeps/sun4/siglist.c:28
msgid "Interrupt"
msgstr "中断"
#: ../sysdeps/osf1/siglist.c:29 ../sysdeps/sun4/siglist.c:29
#: sysdeps/osf1/siglist.c:29 sysdeps/sun4/siglist.c:29
msgid "Quit"
msgstr "退出"
#: ../sysdeps/osf1/siglist.c:30 ../sysdeps/sun4/siglist.c:30
#: sysdeps/osf1/siglist.c:30 sysdeps/sun4/siglist.c:30
msgid "Illegal instruction"
msgstr "非法指令"
#: ../sysdeps/osf1/siglist.c:31 ../sysdeps/sun4/siglist.c:31
#: sysdeps/osf1/siglist.c:31 sysdeps/sun4/siglist.c:31
msgid "Trace trap"
msgstr "跟踪陷阱"
#: ../sysdeps/osf1/siglist.c:32 ../sysdeps/sun4/siglist.c:32
#: sysdeps/osf1/siglist.c:32 sysdeps/sun4/siglist.c:32
msgid "Abort"
msgstr "中止"
#: ../sysdeps/osf1/siglist.c:33 ../sysdeps/sun4/siglist.c:33
#: sysdeps/osf1/siglist.c:33 sysdeps/sun4/siglist.c:33
msgid "EMT error"
msgstr "EMT 错误"
#: ../sysdeps/osf1/siglist.c:34 ../sysdeps/sun4/siglist.c:34
#: sysdeps/osf1/siglist.c:34 sysdeps/sun4/siglist.c:34
msgid "Floating-point exception"
msgstr "浮点意外"
#: ../sysdeps/osf1/siglist.c:35 ../sysdeps/sun4/siglist.c:35
#: sysdeps/osf1/siglist.c:35 sysdeps/sun4/siglist.c:35
msgid "Kill"
msgstr "杀死"
#: ../sysdeps/osf1/siglist.c:36 ../sysdeps/sun4/siglist.c:36
#: sysdeps/osf1/siglist.c:36 sysdeps/sun4/siglist.c:36
msgid "Bus error"
msgstr "总线错误"
#: ../sysdeps/osf1/siglist.c:37 ../sysdeps/sun4/siglist.c:37
#: sysdeps/osf1/siglist.c:37 sysdeps/sun4/siglist.c:37
msgid "Segmentation violation"
msgstr "进程段异常"
#: ../sysdeps/osf1/siglist.c:38 ../sysdeps/sun4/siglist.c:38
#: sysdeps/osf1/siglist.c:38 sysdeps/sun4/siglist.c:38
msgid "Bad argument to system call"
msgstr "系统调用参数错误"
#: ../sysdeps/osf1/siglist.c:39 ../sysdeps/sun4/siglist.c:39
#: sysdeps/osf1/siglist.c:39 sysdeps/sun4/siglist.c:39
msgid "Broken pipe"
msgstr "损坏的通道"
#: ../sysdeps/osf1/siglist.c:40 ../sysdeps/sun4/siglist.c:40
#: sysdeps/osf1/siglist.c:40 sysdeps/sun4/siglist.c:40
msgid "Alarm clock"
msgstr "警告时钟"
#: ../sysdeps/osf1/siglist.c:41 ../sysdeps/sun4/siglist.c:41
#: sysdeps/osf1/siglist.c:41 sysdeps/sun4/siglist.c:41
msgid "Termination"
msgstr "终止"
#: ../sysdeps/osf1/siglist.c:42 ../sysdeps/sun4/siglist.c:42
#: sysdeps/osf1/siglist.c:42 sysdeps/sun4/siglist.c:42
msgid "Urgent condition on socket"
msgstr "套接字紧急条件"
#: ../sysdeps/osf1/siglist.c:43 ../sysdeps/sun4/siglist.c:43
#: sysdeps/osf1/siglist.c:43 sysdeps/sun4/siglist.c:43
msgid "Stop"
msgstr "停止"
#: ../sysdeps/osf1/siglist.c:44 ../sysdeps/sun4/siglist.c:44
#: sysdeps/osf1/siglist.c:44 sysdeps/sun4/siglist.c:44
msgid "Keyboard stop"
msgstr "键盘停止"
#: ../sysdeps/osf1/siglist.c:45 ../sysdeps/sun4/siglist.c:45
#: sysdeps/osf1/siglist.c:45 sysdeps/sun4/siglist.c:45
msgid "Continue"
msgstr "继续"
#: ../sysdeps/osf1/siglist.c:46 ../sysdeps/sun4/siglist.c:46
#: sysdeps/osf1/siglist.c:46 sysdeps/sun4/siglist.c:46
msgid "Child status has changed"
msgstr "子状态变更"
#: ../sysdeps/osf1/siglist.c:47 ../sysdeps/sun4/siglist.c:47
#: sysdeps/osf1/siglist.c:47 sysdeps/sun4/siglist.c:47
msgid "Background read from tty"
msgstr "后台从 tty 读取"
#: ../sysdeps/osf1/siglist.c:48 ../sysdeps/sun4/siglist.c:48
#: sysdeps/osf1/siglist.c:48 sysdeps/sun4/siglist.c:48
msgid "Background write to tty"
msgstr "后台写到 tty"
#: ../sysdeps/osf1/siglist.c:49 ../sysdeps/sun4/siglist.c:49
#: sysdeps/osf1/siglist.c:49 sysdeps/sun4/siglist.c:49
msgid "I/O now possible"
msgstr "现可以 I/O"
#: ../sysdeps/osf1/siglist.c:50 ../sysdeps/sun4/siglist.c:50
#: sysdeps/osf1/siglist.c:50 sysdeps/sun4/siglist.c:50
msgid "CPU limit exceeded"
msgstr "达到 CPU 限制"
#: ../sysdeps/osf1/siglist.c:51 ../sysdeps/sun4/siglist.c:51
#: sysdeps/osf1/siglist.c:51 sysdeps/sun4/siglist.c:51
msgid "File size limit exceeded"
msgstr "达到文件大小限制"
#: ../sysdeps/osf1/siglist.c:52 ../sysdeps/sun4/siglist.c:52
#: sysdeps/osf1/siglist.c:52 sysdeps/sun4/siglist.c:52
msgid "Virtual alarm clock"
msgstr "虚拟警报时钟"
#: ../sysdeps/osf1/siglist.c:53 ../sysdeps/sun4/siglist.c:53
#: sysdeps/osf1/siglist.c:53 sysdeps/sun4/siglist.c:53
msgid "Profiling alarm clock"
msgstr "个性化警报时钟"
#: ../sysdeps/osf1/siglist.c:54 ../sysdeps/sun4/siglist.c:54
#: sysdeps/osf1/siglist.c:54 sysdeps/sun4/siglist.c:54
msgid "Window size change"
msgstr "窗口大小更改"
#: ../sysdeps/osf1/siglist.c:55 ../sysdeps/sun4/siglist.c:55
#: sysdeps/osf1/siglist.c:55 sysdeps/sun4/siglist.c:55
msgid "Information request"
msgstr "信息请求"
#: ../sysdeps/osf1/siglist.c:56 ../sysdeps/sun4/siglist.c:56
#: sysdeps/osf1/siglist.c:56 sysdeps/sun4/siglist.c:56
msgid "User defined signal 1"
msgstr "用户自定义信号 1"
#: ../sysdeps/osf1/siglist.c:57 ../sysdeps/sun4/siglist.c:57
#: sysdeps/osf1/siglist.c:57 sysdeps/sun4/siglist.c:57
msgid "User defined signal 2"
msgstr "用户自定义信号 2"

View File

@@ -55,6 +55,16 @@ static gulong mem_get_by_bytes (glibtop *server, const char *name) {
return result;
}
static gulong try_mem_get_by_bytes (glibtop *server, const char *name) {
gulong result = 0;
size_t len = sizeof (result);
if (sysctlbyname (name, &result, &len, NULL, 0)) {
return 0;
}
return result;
}
static gulong mem_get_by_pages (glibtop *server, const char *name) {
guint result = 0;
size_t len = sizeof (result);
@@ -71,29 +81,35 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
gulong memtotal;
gulong memactive;
gulong meminactive;
gulong memlaundry;
gulong memwired;
gulong memcached;
gulong membuffer;
gulong memfree;
gulong zfs_arc_size;
memset (buf, 0, sizeof *buf);
memtotal = mem_get_by_bytes (server, "hw.physmem");
memactive = mem_get_by_pages (server, "vm.stats.vm.v_active_count");
meminactive = mem_get_by_pages (server, "vm.stats.vm.v_inactive_count");
memlaundry = mem_get_by_pages (server, "vm.stats.vm.v_laundry_count");
memwired = mem_get_by_pages (server, "vm.stats.vm.v_wire_count");
memcached = mem_get_by_pages (server, "vm.stats.vm.v_cache_count");
membuffer = mem_get_by_bytes (server, "vfs.bufspace");
memfree = mem_get_by_pages (server, "vm.stats.vm.v_free_count");
zfs_arc_size = try_mem_get_by_bytes (server, "kstat.zfs.misc.arcstats.size");
buf->total = memtotal;
buf->used = memtotal - memfree;
buf->free = memfree;
buf->shared = 0;
buf->buffer = membuffer;
buf->cached = memcached;
buf->cached = memcached + zfs_arc_size;
buf->locked = 0;
buf->user = memactive + memwired;
buf->user = memactive + memlaundry + memwired - zfs_arc_size;
buf->flags = _glibtop_sysdeps_mem;
}

View File

@@ -1,6 +1,6 @@
AM_CPPFLAGS = @AM_CPPFLAGS@
noinst_LTLIBRARIES = libgtop_sysdeps-2.0.la
noinst_LTLIBRARIES = libgtop_sysdeps-2.0.la libgtop_sysdeps_suid-2.0.la
EXTRA_DIST = procmap_smaps.gperf procmap_smaps.c
@@ -17,7 +17,9 @@ libgtop_sysdeps_2_0_la_LIBADD = @GLIB_LIBS@
# libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
libgtopinclude_HEADERS = glibtop_server.h glibtop_machine.h
libgtop_sysdeps_suid_2_0_la_SOURCES = suid_open.c
libgtopinclude_HEADERS = glibtop_server.h glibtop_machine.h glibtop_suid.h
libgtopincludedir = $(includedir)/libgtop-2.0
noinst_HEADERS = glibtop_private.h

View File

@@ -28,6 +28,10 @@ G_BEGIN_DECLS
struct _glibtop_machine
{
uid_t uid;
uid_t euid;
gid_t gid;
gid_t egid;
};
G_END_DECLS

View File

@@ -0,0 +1,49 @@
/* Copyright (C) 2018 Benoît Dejean
LibGTop 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.
LibGTop 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 LibGTop; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GLIBTOP_SUID_H__
#define __GLIBTOP_SUID_H__
G_BEGIN_DECLS
#include <glibtop_machine.h>
static inline void glibtop_suid_enter (glibtop *server) {
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
setreuid (server->machine->uid, server->machine->euid);
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
};
static inline void glibtop_suid_leave (glibtop *server) {
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
if (setreuid (server->machine->euid, server->machine->uid))
_exit (1);
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
};
void
glibtop_init_p (glibtop *server, const unsigned long features,
const unsigned flags);
void
glibtop_open_p (glibtop *server, const char *program_name,
const unsigned long features,
const unsigned flags);
G_END_DECLS
#endif

View File

@@ -136,7 +136,7 @@ parse_line(char* line,
{
/* %16llx-%16llx %4c %16llx %02hx:%02hx %llu%*[ ]%n */
char *p, *next;
char *p;
p = line;

View File

@@ -0,0 +1,334 @@
/*
Don't forget to set
#define GLIBTOP_SUID_PROC_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP)
in sysdeps/linux/glibtop_server.h
Make sure to pair each glibtop_suid_enter with a glibtop_suid_leave.
*/
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
LibGTop 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.
LibGTop 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 LibGTop; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <config.h>
#include <glib.h>
#include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/procmap.h>
#include <linux/kdev_t.h>
#include <stddef.h>
#include "glibtop_private.h"
#include "glibtop_suid.h"
#include "procmap_smaps.c"
#define MAPS_FILE "/proc/%u/maps"
#define SMAPS_FILE "/proc/%u/smaps"
#define PROC_MAPS_FORMAT "%16" G_GINT64_MODIFIER "x-%16" G_GINT64_MODIFIER "x %4c %16" G_GINT64_MODIFIER "x %02hx:%02hx %" G_GINT64_MODIFIER "u%*[ ]%n"
static const unsigned long _glibtop_sysdeps_proc_map =
(1L << GLIBTOP_PROC_MAP_NUMBER) + (1L << GLIBTOP_PROC_MAP_TOTAL) +
(1L << GLIBTOP_PROC_MAP_SIZE);
static const unsigned long _glibtop_sysdeps_map_entry =
(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) +
(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM) +
(1L << GLIBTOP_MAP_ENTRY_INODE) + (1L << GLIBTOP_MAP_ENTRY_DEVICE) +
(1L << GLIBTOP_MAP_ENTRY_FILENAME);
static const unsigned long _glibtop_sysdeps_map_entry_smaps =
(1UL << GLIBTOP_MAP_ENTRY_SIZE) + (1UL << GLIBTOP_MAP_ENTRY_RSS) +
(1UL << GLIBTOP_MAP_ENTRY_PSS) + (1UL << GLIBTOP_MAP_ENTRY_SWAP) +
(1UL << GLIBTOP_MAP_ENTRY_SHARED_DIRTY) + (1UL << GLIBTOP_MAP_ENTRY_SHARED_CLEAN) +
(1UL << GLIBTOP_MAP_ENTRY_PRIVATE_DIRTY) + (1UL << GLIBTOP_MAP_ENTRY_PRIVATE_CLEAN);
/* Init function. */
void
_glibtop_init_proc_map_p (glibtop *server)
{
server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
}
/* Provides detailed information about a process. */
static const char*
is_smap_value(const char* s)
{
for ( ; *s; ++s) {
if (isspace(*s))
return NULL;
if (*s == ':')
return s;
}
return NULL;
}
/*
Returns whether line is a 'value' line
and add if we know its meaning
*/
static gboolean
parse_smaps(glibtop_map_entry *entry, const char* line)
{
const struct smap_value* smap;
size_t len;
const char* colon;
if ((colon = is_smap_value(line)) == NULL)
return FALSE;
len = colon - line;
smap = _glibtop_find_smap(line, len);
// g_debug("smap %s -> %p", line, smap);
if (smap) {
char *offset;
guint64 *value;
offset = (void*) entry;
offset += smap->offset;
value = (void*) offset;
*value = get_scaled(line + len, NULL);
}
return TRUE;
}
/*
sscanf is too slow
and system-monitor calls procmap for each pid every second
manual parsing is faster
error checking is weaker
*/
static gboolean
parse_line(char* line,
guint64* start, guint64* end, char flags[4], guint64* offset,
gushort* dev_major, gushort* dev_minor, guint64* inode,
char** filename)
{
/* %16llx-%16llx %4c %16llx %02hx:%02hx %llu%*[ ]%n */
char *p, *next;
p = line;
*start = strtoull(p, &p, 16);
if (G_UNLIKELY(*p != '-'))
return FALSE;
p++;
*end = strtoull(p, &p, 16);
p = next_token(p);
memcpy(flags, p, 4);
p += 4;
*offset = strtoull(p, &p, 16);
*dev_major = strtoul(p, &p, 16);
if (G_UNLIKELY(*p != ':'))
return FALSE;
p++;
*dev_minor = strtoul(p, &p, 16);
*inode = strtoull(p, &p, 10);
p = next_token(p);
*filename = p;
for ( ; *p; p++) {
if (*p == '\n') {
*p = '\0';
break;
}
}
return TRUE;
}
glibtop_map_entry *
glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf, pid_t pid)
{
char procfilename[GLIBTOP_MAP_FILENAME_LEN+1];
/*
default size of 100 maybe inaccurate.
It's the average number of entry per process on my laptop
*/
size_t added = 0, entry_list_capacity = 100;
GArray *entry_list = g_array_sized_new(FALSE, FALSE,
sizeof(glibtop_map_entry),
entry_list_capacity);
FILE *maps;
const char *filename;
gboolean has_smaps;
char *line = NULL;
size_t line_size = 0;
memset (buf, 0, sizeof (glibtop_proc_map));
has_smaps = server->os_version_code >= LINUX_VERSION_CODE(2, 6, 14);
if (has_smaps)
filename = SMAPS_FILE;
else
filename = MAPS_FILE;
snprintf (procfilename, sizeof procfilename, filename, (unsigned)pid);
glibtop_suid_enter (server);
if((maps = fopen (procfilename, "r")) == NULL) {
glibtop_suid_leave (server);
return (glibtop_map_entry*) g_array_free(entry_list, TRUE);
}
glibtop_debug("opened %p", maps);
glibtop_suid_leave (server);
while(TRUE)
{
unsigned long perm;
/* int line_end; */
unsigned short dev_major, dev_minor;
guint64 start, end, offset, inode;
char flags[4];
char *filename;
glibtop_map_entry *entry;
if (getline(&line, &line_size, maps) == -1)
break;
new_entry_line:
if (!parse_line(line,
&start, &end, flags, &offset,
&dev_major, &dev_minor, &inode, &filename))
continue;
/*
if (sscanf(line, PROC_MAPS_FORMAT,
&start, &end, flags, &offset,
&dev_major, &dev_minor, &inode, &line_end) != 7)
continue;
filename = line + line_end;
g_strstrip(filename);
*/
/* Compute access permissions. */
perm = 0;
if (flags [0] == 'r')
perm |= GLIBTOP_MAP_PERM_READ;
if (flags [1] == 'w')
perm |= GLIBTOP_MAP_PERM_WRITE;
if (flags [2] == 'x')
perm |= GLIBTOP_MAP_PERM_EXECUTE;
if (flags [3] == 's')
perm |= GLIBTOP_MAP_PERM_SHARED;
else if (flags [3] == 'p')
perm |= GLIBTOP_MAP_PERM_PRIVATE;
/*
avoid copying the entry, grow by 1 and point to the last
element.
*/
if (G_UNLIKELY(added >= entry_list_capacity)) {
entry_list_capacity *= 2;
g_array_set_size(entry_list, entry_list_capacity);
}
entry = &g_array_index(entry_list, glibtop_map_entry, added++);
entry->flags = _glibtop_sysdeps_map_entry;
entry->start = start;
entry->end = end;
entry->offset = offset;
entry->perm = perm;
entry->device = MKDEV(dev_major, dev_minor);
entry->inode = inode;
g_strlcpy(entry->filename, filename, sizeof entry->filename);
if (has_smaps) {
ssize_t ret;
entry->flags |= _glibtop_sysdeps_map_entry_smaps;
while ((ret = getline(&line, &line_size, maps)) != -1) {
if (!parse_smaps(entry, line))
goto new_entry_line;
}
if (ret == -1)
goto eof;
}
}
eof:
g_array_set_size(entry_list, added);
free(line);
fclose (maps);
buf->flags = _glibtop_sysdeps_proc_map;
buf->number = added;
buf->size = sizeof (glibtop_map_entry);
buf->total = buf->number * buf->size;
return (glibtop_map_entry*) g_array_free(entry_list, FALSE);
}

View File

@@ -35,7 +35,7 @@ static const unsigned long _glibtop_sysdeps_proc_mem_pss =
static unsigned long
get_pss(glibtop* server, pid_t pid)
G_GNUC_UNUSED get_pss(glibtop* server, pid_t pid)
{
char filepath[128];
FILE* smaps;
@@ -86,7 +86,7 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
memset (buf, 0, sizeof (glibtop_proc_mem));
/* As of 2.6.24 in fs/proc/*.c
/* As of 2.6.24 in fs/proc/ *.c
== rss vs. resident ==

80
sysdeps/linux/suid_open.c Normal file
View File

@@ -0,0 +1,80 @@
/* Copyright (C) 2018 Benoît Dejean
LibGTop 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.
LibGTop 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 LibGTop; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <config.h>
#include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/cpu.h>
#include <glibtop/open.h>
#include <glibtop/init_hooks.h>
#include <glibtop/machine.h>
/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
void
glibtop_init_p (glibtop *server, const unsigned long features,
const unsigned flags)
{
const _glibtop_init_func_t *init_fkt;
if (server == NULL)
glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
/* Do the initialization, but only if not already initialized. */
if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) {
glibtop_open_p (server, "glibtop", features, flags);
for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
(*init_fkt) (server);
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
}
}
void
glibtop_open_p (glibtop *server, const char *program_name,
const unsigned long features,
const unsigned flags)
{
glibtop_debug ("glibtop_open_p ()");
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
server->machine->uid = getuid ();
server->machine->euid = geteuid ();
server->machine->gid = getgid ();
server->machine->egid = getegid ();
/* Drop priviledges. */
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
if (setreuid (server->machine->euid, server->machine->uid))
_exit (1);
if (setregid (server->machine->egid, server->machine->gid))
_exit (1);
glibtop_debug ("uid=%d euid=%d gid=%d egid=%d", getuid(), geteuid(), getgid(), getegid());
/* !!! END OF SUID ROOT PART !!! */
/* Our effective uid is now those of the user invoking the server,
* so we do no longer have any priviledges. */
}