├── AUTHORS ├── Makefile.am ├── README ├── Resources └── Tasks │ └── GoboHide ├── autoclean.sh ├── autogen.sh ├── configure.ac ├── m4 └── Makefile.am ├── man ├── Makefile.am ├── man7 │ └── hier.7 └── man8 │ └── gobohide.8 ├── po ├── LINGUAS ├── Makevars ├── POTFILES.in ├── eo_EO.po ├── es_ES.po ├── hu_HU.po └── pt_BR.po └── src ├── Makefile.am ├── gobohide.c ├── gobohide.conf └── gobohide.h /AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gobolinux/GoboHide/e0813b7648ceb98e70b89c7e2514e0a9177345d5/AUTHORS -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign no-dependencies 2 | ACLOCAL_AMFLAGS = -I m4 3 | 4 | EXTRA_DIST = BUGS \ 5 | COPYING \ 6 | ChangeLog \ 7 | INSTALL \ 8 | README \ 9 | FAQ 10 | 11 | SUBDIRS = m4 po man src 12 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Please see https://gobolinux.org/doc/articles/gobohide.html 2 | for more information on this package. 3 | -------------------------------------------------------------------------------- /Resources/Tasks/GoboHide: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | case "$1" in 4 | [sS]tart) 5 | option="-h" 6 | ;; 7 | [sS]top) 8 | option="-u" 9 | ;; 10 | *) 11 | echo "Usage: $0 " 12 | exit 1 13 | esac 14 | 15 | for dir in /bin /etc /lib /sbin /tmp /var /usr /proc /dev /sys /srv /mnt /media /boot 16 | do 17 | if [ -d "$dir" -o -h "$dir" ] 18 | then 19 | gobohide "$option" "$dir" 20 | fi 21 | done 22 | -------------------------------------------------------------------------------- /autoclean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Example for use of GNU gettext. 3 | # Copyright (C) 2003-2004 Free Software Foundation, Inc. 4 | # This file is in the public domain. 5 | # 6 | # Script for cleaning all autogenerated files. 7 | 8 | test ! -f Makefile || make distclean 9 | 10 | # Brought in by autopoint. 11 | rm -f ABOUT-NLS 12 | rm -f config.rpath 13 | rm -f m4/codeset.m4 14 | rm -f m4/gettext.m4 15 | rm -f m4/glibc21.m4 16 | rm -f m4/iconv.m4 17 | rm -f m4/intdiv0.m4 18 | rm -f m4/intmax.m4 19 | rm -f m4/inttypes-pri.m4 20 | rm -f m4/inttypes.m4 21 | rm -f m4/inttypes_h.m4 22 | rm -f m4/isc-posix.m4 23 | rm -f m4/lcmessage.m4 24 | rm -f m4/lib-ld.m4 25 | rm -f m4/lib-link.m4 26 | rm -f m4/lib-prefix.m4 27 | rm -f m4/longdouble.m4 28 | rm -f m4/longlong.m4 29 | rm -f m4/nls.m4 30 | rm -f m4/po.m4 31 | rm -f m4/printf-posix.m4 32 | rm -f m4/progtest.m4 33 | rm -f m4/signed.m4 34 | rm -f m4/size_max.m4 35 | rm -f m4/stdint_h.m4 36 | rm -f m4/uintmax_t.m4 37 | rm -f m4/ulonglong.m4 38 | rm -f m4/wchar_t.m4 39 | rm -f m4/wint_t.m4 40 | rm -f m4/xsize.m4 41 | rm -f mkinstalldirs 42 | rm -f po/Makefile.in.in 43 | rm -f po/remove-potcdate.sin 44 | 45 | # Generated by aclocal. 46 | rm -f aclocal.m4 47 | 48 | # Generated by autoconf. 49 | rm -f configure 50 | 51 | # Generated or brought in by automake. 52 | rm -f Makefile.in 53 | rm -f m4/Makefile.in 54 | rm -f install-sh 55 | rm -f missing 56 | rm -f config.guess 57 | rm -f config.sub 58 | rm -f po/*.pot 59 | rm -f po/stamp-po 60 | rm -f po/*.gmo 61 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autopoint -f 4 | rm po/Makevars.template 5 | rm po/Rules-quot 6 | rm po/boldquot.sed 7 | rm po/en@boldquot.header 8 | rm po/en@quot.header 9 | rm po/insert-header.sin 10 | rm po/quot.sed 11 | 12 | aclocal -I m4 13 | autoreconf -i 14 | 15 | cd po 16 | for f in *.po; do 17 | if test -r "$f"; then 18 | lang=`echo $f | sed -e 's,\.po$,,'` 19 | msgfmt -c -o $lang.gmo $lang.po 20 | fi 21 | done 22 | cd .. 23 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl 2 | dnl configure.in file for GoboHide 3 | dnl 4 | 5 | AC_INIT([gobohide], [1.0]) 6 | AC_CONFIG_SRCDIR(src/gobohide.c) 7 | AC_CONFIG_MACRO_DIRS([m4]) 8 | AC_PROG_CC 9 | AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no]) 10 | if test "x$PKGCONFIG" = "xno" 11 | then 12 | AC_MSG_ERROR([pkg-config not found]) 13 | fi 14 | 15 | AM_INIT_AUTOMAKE 16 | AM_PROG_LIBTOOL 17 | AM_GNU_GETTEXT([external]) 18 | AM_GNU_GETTEXT_VERSION(0.13.1) 19 | 20 | PKG_CHECK_MODULES(LIBNL3, libnl-3.0 >= 3.1, [true], 21 | AC_MSG_ERROR([netlink library (libnl) not found])) 22 | PKG_CHECK_MODULES(LIBNL3_GENL, libnl-genl-3.0 >= 3.1, [true], 23 | AC_MSG_ERROR([generic netlink library (libnl-genl) not found])) 24 | PKG_CHECK_MODULES(LIBNL3_CLI, libnl-cli-3.0 >= 3.1, [true], 25 | AC_MSG_ERROR([generic netlink command line interface library (libnl-cli) not found])) 26 | 27 | CFLAGS="$CFLAGS `$PKGCONFIG --cflags libnl-3.0 libnl-genl-3.0 libnl-cli-3.0`" 28 | LDFLAGS="$LDFLAGS `$PKGCONFIG --libs libnl-3.0 libnl-genl-3.0 libnl-cli-3.0`" 29 | AC_SUBST([CFLAGS]) 30 | AC_SUBST([LDFLAGS]) 31 | 32 | AC_CONFIG_FILES([Makefile]) 33 | AC_CONFIG_FILES([m4/Makefile]) 34 | AC_CONFIG_FILES([po/Makefile.in]) 35 | AC_CONFIG_FILES([man/Makefile]) 36 | AC_CONFIG_FILES([src/Makefile]) 37 | AC_OUTPUT 38 | -------------------------------------------------------------------------------- /m4/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes.m4 \ 3 | inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 \ 4 | lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 \ 5 | ulonglong.m4 6 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | man_MANS = man7/hier.7 \ 2 | man8/gobohide.8 3 | 4 | EXTRA_DIST = $(man_MANS) 5 | -------------------------------------------------------------------------------- /man/man7/hier.7: -------------------------------------------------------------------------------- 1 | .\"This man page was created by Fibo, assistant to Gobo. 2 | .Dd April 21, 2003 3 | .Dt HIER 7 4 | .Os GoboLinux 5 | .Sh NAME 6 | .Nm hier 7 | .Nd layout of file systems 8 | 9 | .Sh DESCRIPTION 10 | A sketch of the file system hierarchy. 11 | 12 | 13 | 14 | \" --------------- / directory --------------- 15 | .Bl -tag -width "/Programs/" 16 | .It Pa / 17 | root directory of the file system 18 | 19 | \" --------------- /Depot directory --------------- 20 | .It Pa /Depot/ 21 | repository for users' files. This repository is meant to be organized as the user sees fit. 22 | No subdirectories of 23 | .Em "/Depot" 24 | are considered part of the standard GoboLinux hierarchy. 25 | 26 | 27 | \" --------------- /Files directory --------------- 28 | .It Pa /Files/ 29 | .Pp 30 | .Bl -tag -width "Documentation/" -compact 31 | .It Pa Codecs/ 32 | codecs used by multimedia players 33 | 34 | 35 | \" --------------- /Files/Documentation directory --------------- 36 | .It Pa Documentation/ 37 | .Pp 38 | .Bl -tag -width "Linux-mini-HOWTOs/" -compact 39 | .It Pa Linux-HOWTOs/ 40 | detailed 41 | .Em how to 42 | documents on specific subjects 43 | .It Pa Linux-mini-HOWTOs/ 44 | detailed 45 | .Em mini how to 46 | documents on specific subjects 47 | .El 48 | 49 | \" --------------- /Files/Fonts directory --------------- 50 | .It Pa Fonts/ 51 | .Pp 52 | .Bl -tag -width "Ghostscript/" -compact 53 | .It Pa 100dpi/ 54 | 100 dpi fonts 55 | .It Pa 75dpi/ 56 | 75 dpi fonts 57 | .It Pa Cyrillic/ 58 | cyrillic fonts 59 | .It Pa Ghostscript/ 60 | ghostscript fonts 61 | .It Pa Misc/ 62 | character-cell fonts, cursor fonts and other low-resolution fonts 63 | .It Pa OTF/ 64 | OpenType fonts 65 | .It Pa Speedo/ 66 | Speedo fonts 67 | .It Pa TrueType/ 68 | TrueType fonts 69 | .It Pa Type1/ 70 | Type 1 fonts. If font metric files are available, they must be placed here as well 71 | .El 72 | 73 | \" --------------- back to /Files directory --------------- 74 | .It Pa Plugins/ 75 | plugins, such as the ones needed by browsers 76 | .El 77 | 78 | 79 | \" --------------- /Mount directory --------------- 80 | .It Pa /Mount/ 81 | mounting point for additional local or remote filesystems 82 | .Pp 83 | .Bl -tag -width "Floppy/" -compact 84 | .It Pa CD-ROM/ 85 | .It Pa Floppy/ 86 | .It Pa Zip/ 87 | .El 88 | 89 | 90 | \" --------------- /Programs directory --------------- 91 | .It Pa /Programs/ 92 | contains a subdirectory for each installed program. Each of those subdirectories has, on its turn, 93 | a subdirectory for each version of the specific program, and a link labeled 94 | .Em Current 95 | pointing to the currently used version. Each program also has a 96 | .Em Settings 97 | directory storing the program's configuration files (which would be normally stored at 98 | .Em /etc 99 | ). This directory is unique for all versions of the program. Each program version may have a 100 | .Em Resources 101 | directory storing program metadata such as dependencies and environment variables. 102 | 103 | 104 | \" --------------- /System directory --------------- 105 | .It Pa /System/ 106 | .Pp 107 | .Bl -tag -width "Executables/" -compact 108 | 109 | \" --------------- /System/Kernel directory --------------- 110 | .It Pa Kernel/ 111 | .Pp 112 | .Bl -tag -width "Devices/" -compact 113 | .It Pa Boot/ 114 | programs and configuration files used during operating system bootstrap 115 | .It Pa Devices/ 116 | device files (managed by the 117 | .Em "dev filesystem" 118 | ). 119 | .It Pa Modules/ 120 | contains the various kernel modules, organized by the kernel release 121 | .It Pa Objects/ 122 | provides a view of the kernel's device tree (introduced with linux-2.6' 123 | .Em "sysfs filesystem" 124 | ) 125 | .It Pa Status/ 126 | kernel status files (managed by the 127 | .Em "proc filesystem" 128 | ). 129 | .El 130 | 131 | \" --------------- /System/Links directory --------------- 132 | .It Pa Links/ 133 | .Pp 134 | .Bl -tag -width "Executables/" -compact 135 | .It Pa Daemons/ 136 | this directory is managed by the runit tool, which supervises the 137 | system daemons. Each entry in this directory corresponds to 138 | a daemon, which can be brought up or down using 139 | .Em "runsvctrl", 140 | or verified with 141 | .Em "runsvstat". 142 | .It Pa Environment/ 143 | links to environment files. These are compiled into a 144 | .Em "Cache" 145 | file and loaded by the shell, allowing programs to register their own 146 | environment variables. 147 | .It Pa Executables/ 148 | contains links to files from the programs' 149 | .Em "bin" 150 | and 151 | .Em "sbin" 152 | directories 153 | .It Pa Headers/ 154 | this directory contains links to files from the programs' 155 | .Em "include" 156 | directories 157 | .It Pa Libraries/ 158 | links to files from the programs' 159 | .Em "lib" 160 | directories 161 | 162 | \" --------------- /System/Links/Manuals directory --------------- 163 | .It Pa Manuals/ 164 | .Pp 165 | .Bl -tag -width "man{1-9}/" -compact 166 | .It Pa info/ 167 | links to files from the programs' 168 | .Em "info" 169 | directories 170 | .It Pa man{1-9}/ 171 | links to files from the programs' 172 | .Em "man{1-9}" 173 | directories 174 | .El 175 | .It Pa Shared/ 176 | links to files from the programs' 177 | .Em "share" 178 | directories 179 | .El 180 | 181 | \" --------------- /System/Settings directory --------------- 182 | .It Pa Settings/ 183 | configuration files and links to files from 184 | .Em "Settings" 185 | directory 186 | .Pp 187 | .Bl -tag -width "BootScripts/" -compact 188 | .It Pa BootScripts/ 189 | scripts used during system boot. Actually, this is a symlink to 190 | .Em "Settings/BootScripts/" 191 | on 192 | .Em "/Programs/BootScripts" 193 | .El 194 | 195 | \" --------------- back to /System directory --------------- 196 | .It Pa Variable/ 197 | multi-purpose log, temporary, transient and spool files 198 | .Pp 199 | .Bl -tag -width "tmp/" -compact 200 | .It Pa tmp/ 201 | temporary files 202 | .El 203 | .El 204 | 205 | 206 | \" --------------- /Users directory --------------- 207 | .It Pa Users/ 208 | personal areas for users 209 | .El 210 | 211 | 212 | .Sh NOTES 213 | Compatibility with the UNIX legacy is obtained through creation of extra links not 214 | present in the tree shown above, such as: 215 | .Bl -compact 216 | .It 217 | .Em "" 218 | .It 219 | .Em "/bin -> /System/Links/Executables," 220 | .It 221 | .Em "/dev -> /System/Status," 222 | .It 223 | .Em "/etc -> /System/Settings," 224 | .It 225 | .Em "/lib -> /System/Links/Libraries," 226 | .It 227 | .Em "/proc -> /System/Status," 228 | .It 229 | .Em "/sbin -> /System/Links/Executables," 230 | .It 231 | .EM "/sys -> /System/Kernel/Objects," 232 | .It 233 | .Em "/tmp -> /System/Variable/tmp," 234 | and 235 | .It 236 | .Em "/var -> /System/Variable," 237 | .It 238 | .Em "" 239 | .El 240 | mirroring the GoboLinux tree into the UNIX tree. These symbolic links and the 241 | .Em "/usr" 242 | directory are gracefully handled by 243 | .Xr gobohide 8 244 | . 245 | 246 | .Sh "SEE ALSO" 247 | gobohide(8), runint(8). 248 | -------------------------------------------------------------------------------- /man/man8/gobohide.8: -------------------------------------------------------------------------------- 1 | .\"This man, along with Gobohide (both user-space and kernel patch) is 2 | .\"Copyright (C) 2003 CScience.ORG World Domination, INC. 3 | .\"Distributed under the GNU General Public License (version 2). 4 | .TH GOBOHIDE 8 "Aug 5, 2003" "Gobohide 0.09" "CScience.ORG World Domination, INC" 5 | .SH NAME 6 | gobohide \- hide/unhide a directory 7 | 8 | .SH SYNOPSYS 9 | .ft B 10 | .B gobohide 11 | .RI < "options" > 12 | .I "TARGET" 13 | 14 | .SH DESCRIPTION 15 | \fBgobohide\fP is a tool used to hide/unhide directories and symbolic links. 16 | 17 | .SH OPTIONS 18 | .TP 19 | .BI "\-h, \-\-hide " 20 | Hides 21 | .I TARGET 22 | . 23 | .TP 24 | 25 | .BI "\-u, \-\-unhide " 26 | Unhides 27 | .I TARGET 28 | . 29 | .TP 30 | 31 | .BI "\-l, \-\-list " 32 | List the hidden directories/symlinks. 33 | .TP 34 | 35 | .BI "\-f, \-\-flush " 36 | Flush the hide list. This is equivalent to unhiding all the 37 | directories/symbolic links one by one. 38 | .TP 39 | 40 | .B "\-v, \-\-version" 41 | Show version information on the standard output and exit successfully. 42 | .TP 43 | 44 | .B "\-h, \-\-help" 45 | Display a usage message on standard output and exit successfully. 46 | 47 | 48 | .SH AUTHORS 49 | 50 | GoboHide was written by 51 | 52 | Felipe W Damasio 53 | .br 54 | felipewd@terra.com.br 55 | .PP 56 | Lucas Correia Villa Real 57 | .br 58 | lucasvr@gobolinux.org 59 | -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- 1 | # Set of available languages. 2 | hu_HU pt_BR eo_EO es_ES 3 | -------------------------------------------------------------------------------- /po/Makevars: -------------------------------------------------------------------------------- 1 | # Makefile variables for PO directory in any package using GNU gettext. 2 | 3 | # Usually the message domain is the same as the package name. 4 | DOMAIN = $(PACKAGE) 5 | 6 | # These two variables depend on the location of this directory. 7 | subdir = po 8 | top_builddir = .. 9 | 10 | # These options get passed to xgettext. 11 | XGETTEXT_OPTIONS = \ 12 | --keyword=_ --flag=_:1:pass-c-format \ 13 | --keyword=N_ --flag=N_:1:pass-c-format 14 | 15 | # This is the copyright holder that gets inserted into the header of the 16 | # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 17 | # package. (Note that the msgstr strings, extracted from the package's 18 | # sources, belong to the copyright holder of the package.) Translators are 19 | # expected to transfer the copyright for their translations to this person 20 | # or entity, or to disclaim their copyright. The empty string stands for 21 | # the public domain; in this case the translators are expected to disclaim 22 | # their copyright. 23 | COPYRIGHT_HOLDER = Lucas C. Villa Real 24 | 25 | # This is the email address or URL to which the translators shall report 26 | # bugs in the untranslated strings: 27 | # - Strings which are not entire sentences, see the maintainer guidelines 28 | # in the GNU gettext documentation, section 'Preparing Strings'. 29 | # - Strings which use unclear terms or require additional context to be 30 | # understood. 31 | # - Strings which make invalid assumptions about notation of date, time or 32 | # money. 33 | # - Pluralisation problems. 34 | # - Incorrect English spelling. 35 | # - Incorrect formatting. 36 | # It can be your email address, or a mailing list address where translators 37 | # can write to without being subscribed, or the URL of a web page through 38 | # which the translators can contact you. 39 | MSGID_BUGS_ADDRESS = lucasvr@gobolinux.org 40 | 41 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 42 | # message catalogs shall be used. It is usually empty. 43 | EXTRA_LOCALE_CATEGORIES = 44 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | # List of source files containing translatable strings. 2 | 3 | src/gobohide.c 4 | -------------------------------------------------------------------------------- /po/eo_EO.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gobolinux/GoboHide/e0813b7648ceb98e70b89c7e2514e0a9177345d5/po/eo_EO.po -------------------------------------------------------------------------------- /po/es_ES.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gobolinux/GoboHide/e0813b7648ceb98e70b89c7e2514e0a9177345d5/po/es_ES.po -------------------------------------------------------------------------------- /po/hu_HU.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gobolinux/GoboHide/e0813b7648ceb98e70b89c7e2514e0a9177345d5/po/hu_HU.po -------------------------------------------------------------------------------- /po/pt_BR.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gobolinux/GoboHide/e0813b7648ceb98e70b89c7e2514e0a9177345d5/po/pt_BR.po -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign no-dependencies 2 | 3 | # Define a C macro LOCALEDIR indicating where catalogs will be installed. 4 | localedir = $(datadir)/locale 5 | DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ 6 | 7 | # Link time dependencies. 8 | LDADD = @LIBINTL@ 9 | 10 | bin_PROGRAMS = gobohide 11 | gobohide_SOURCES = gobohide.c 12 | sysconf_DATA = gobohide.conf 13 | -------------------------------------------------------------------------------- /src/gobohide.c: -------------------------------------------------------------------------------- 1 | /* gobohide.c: Set/Unset the "hide directory" flag to a directory */ 2 | 3 | /* 4 | * Copyright (C) 2002-2016 GoboLinux.org 5 | * 6 | * This program is Free Software; you can redistributed it 7 | * and/or modify it under the terms of the GNU General Public 8 | * License as published by the Free Software Foundation. 9 | * 10 | * Authors: Felipe W Damasio 11 | * Lucas C. Villa Real 12 | */ 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "gobohide.h" 31 | 32 | static struct nla_policy gobohide_kernel2user_policy[GOBOHIDE_TYPE_MAX+1] = { 33 | [GOBOHIDE_TYPE_PATH] = { .type = NLA_STRING }, 34 | [GOBOHIDE_TYPE_LIST_SIZE] = { .type = NLA_U32 }, 35 | }; 36 | 37 | #define _(message) gettext(message) 38 | 39 | static const char version[] = "1.0"; 40 | static uint32_t gobohide_list_size; 41 | 42 | static int parse_cmd_list_size(struct nl_cache_ops *unused, struct genl_cmd *cmd, 43 | struct genl_info *info, void *arg) 44 | { 45 | if (! info->attrs[GOBOHIDE_TYPE_LIST_SIZE]) { 46 | fprintf(stderr, "Invalid reply message received\n"); 47 | return NL_SKIP; 48 | } 49 | gobohide_list_size = nla_get_u32(info->attrs[GOBOHIDE_TYPE_LIST_SIZE]); 50 | return 0; 51 | } 52 | 53 | static int parse_cmd_list_reply(struct nl_cache_ops *unused, struct genl_cmd *cmd, 54 | struct genl_info *info, void *arg) 55 | { 56 | struct nlattr *attrs[GOBOHIDE_TYPE_MAX+1]; 57 | char *pathattr; 58 | int ret; 59 | 60 | if (! info->attrs[GOBOHIDE_TYPE_PATH]) { 61 | fprintf(stderr, "Invalid reply message received\n"); 62 | return NL_SKIP; 63 | } 64 | 65 | ret = nla_parse(attrs, GOBOHIDE_TYPE_MAX, info->attrs[GOBOHIDE_TYPE_PATH], 66 | PATH_MAX, gobohide_kernel2user_policy); 67 | if (ret < 0) { 68 | nl_perror(ret, "Error while parsing the generic netlink message"); 69 | return ret; 70 | } 71 | 72 | pathattr = nla_get_string(attrs[GOBOHIDE_TYPE_PATH]); 73 | if (! pathattr) { 74 | fprintf(stderr, "Error while parsing ATTR_PATH\n"); 75 | return NL_SKIP; 76 | } 77 | printf("%s\n", pathattr); 78 | return 0; 79 | } 80 | 81 | static int parse_cb(struct nl_msg *msg, void *arg) 82 | { 83 | return genl_handle_msg(msg, NULL); 84 | } 85 | 86 | static struct genl_cmd cmds[] = { 87 | { 88 | .c_id = GOBOHIDE_CMD_LIST_SIZE, 89 | .c_name = "GOBOHIDE_LIST_SIZE", 90 | .c_maxattr = GOBOHIDE_CMD_MAX, 91 | .c_attr_policy = gobohide_kernel2user_policy, 92 | .c_msg_parser = &parse_cmd_list_size, 93 | }, 94 | { 95 | .c_id = GOBOHIDE_CMD_LIST_REPLY, 96 | .c_name = "GOBOHIDE_LIST_REPLY", 97 | .c_maxattr = GOBOHIDE_CMD_MAX, 98 | .c_attr_policy = gobohide_kernel2user_policy, 99 | .c_msg_parser = &parse_cmd_list_reply, 100 | }, 101 | }; 102 | 103 | #define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) 104 | 105 | static struct genl_ops ops = { 106 | .o_name = "gobohide", 107 | .o_cmds = cmds, 108 | .o_ncmds = ARRAY_SIZE(cmds), 109 | }; 110 | 111 | static void init_netlink() 112 | { 113 | int ret = genl_register_family(&ops); 114 | if (ret < 0) 115 | nl_cli_fatal(ret, "Unable to register Generic Netlink family"); 116 | } 117 | 118 | static int send_netlink_cmd(int command, ino_t ino, char *pathname) 119 | { 120 | struct nl_sock *sock; 121 | struct nl_msg *msg; 122 | void *hdr; 123 | int ret; 124 | 125 | sock = nl_cli_alloc_socket(); 126 | nl_cli_connect(sock, NETLINK_GENERIC); 127 | 128 | if ((ret = genl_ops_resolve(sock, &ops)) < 0) 129 | nl_cli_fatal(ret, "Unable to resolve family name"); 130 | 131 | if (genl_ctrl_resolve(sock, "nlctrl") != GENL_ID_CTRL) 132 | nl_cli_fatal(NLE_INVAL, "Resolving of \"nlctrl\" failed"); 133 | 134 | msg = nlmsg_alloc(); 135 | if (msg == NULL) 136 | nl_cli_fatal(NLE_NOMEM, "Unable to allocate netlink message"); 137 | 138 | hdr = genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, ops.o_id, 0, 0, command, 0x01); 139 | if (hdr == NULL) 140 | nl_cli_fatal(ENOMEM, "Unable to write genl header"); 141 | 142 | switch (command) { 143 | case GOBOHIDE_CMD_HIDE: 144 | case GOBOHIDE_CMD_UNHIDE: 145 | if ((ret = nla_put_u64(msg, GOBOHIDE_CMD_ATTR_INODE, ino)) < 0) 146 | nl_cli_fatal(ret, "Unable to add attribute: %s", nl_geterror(ret)); 147 | if ((ret = nla_put_string(msg, GOBOHIDE_CMD_ATTR_PATH, pathname)) < 0) 148 | nl_cli_fatal(ret, "Unable to add attribute: %s", nl_geterror(ret)); 149 | break; 150 | 151 | case GOBOHIDE_CMD_FLUSH: 152 | case GOBOHIDE_CMD_LIST: 153 | break; 154 | } 155 | 156 | if ((ret = nl_send_auto_complete(sock, msg)) < 0) 157 | nl_cli_fatal(ret, "Unable to send message: %s", nl_geterror(ret)); 158 | 159 | nlmsg_free(msg); 160 | 161 | if (command == GOBOHIDE_CMD_LIST) { 162 | int msgs = 0; 163 | 164 | ret = nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, parse_cb, NULL); 165 | if (ret < 0) 166 | nl_cli_fatal(ret, "Unable to modify valid message callback"); 167 | 168 | while ((ret = nl_recvmsgs_default(sock)) >= 0) { 169 | /* let the callback process the message */ 170 | msgs++; 171 | /* check local counter against global */ 172 | if (msgs > gobohide_list_size) 173 | break; 174 | } 175 | } 176 | 177 | nl_close(sock); 178 | nl_socket_free(sock); 179 | 180 | return 0; 181 | } 182 | 183 | void err_quit(int status, char *file) 184 | { 185 | fprintf(stderr, _("%s is neither a directory " 186 | "nor a symbolic link\n"), file); 187 | exit(status); 188 | } 189 | 190 | int cmd_hide_unhide(char *pathname, int operation) 191 | { 192 | struct stat stats; 193 | int fd; 194 | 195 | if (strlen(pathname) > PATH_MAX-1) { 196 | fprintf(stderr, "Error: %s > PATH_MAX\n", pathname); 197 | exit(EXIT_FAILURE); 198 | } 199 | 200 | /* We're only interested in directories */ 201 | fd = open(pathname, O_RDONLY|O_NOFOLLOW); 202 | if (fd < 0) { /* We're opening a symlink */ 203 | if (lstat(pathname, &stats) == -1) { /* Do not follow the link */ 204 | perror("lstat"); 205 | exit(EXIT_FAILURE); 206 | } 207 | if (!S_ISLNK(stats.st_mode)) 208 | err_quit(1, pathname); 209 | } else { 210 | /* We opened a directory, let's get its inode number */ 211 | if (fstat(fd, &stats) == -1) { 212 | perror("fstat"); 213 | exit(EXIT_FAILURE); 214 | } 215 | if (!S_ISDIR(stats.st_mode)) 216 | err_quit(1, pathname); 217 | } 218 | close (fd); 219 | 220 | return send_netlink_cmd(operation, stats.st_ino, pathname); 221 | } 222 | 223 | int cmd_flush() 224 | { 225 | int ret; 226 | ret = send_netlink_cmd(GOBOHIDE_CMD_FLUSH, 0, NULL); 227 | return ret; 228 | } 229 | 230 | int cmd_list() 231 | { 232 | int ret; 233 | ret = send_netlink_cmd(GOBOHIDE_CMD_LIST, 0, NULL); 234 | return ret; 235 | } 236 | 237 | void usage(char *program_name, int status) 238 | { 239 | if (status) { /* Show help */ 240 | fprintf(stdout, _( 241 | "%s: Hide/Unhide a directory\n\n" 242 | "-h, --hide Hide the directory\n" 243 | "-u, --unhide Unhide the directory\n" 244 | "-l, --list List the hidden directories\n" 245 | "-f, --flush Flush the hide list\n" 246 | " --version Show the program version\n" 247 | " --help Show this message\n"), 248 | program_name); 249 | } else { 250 | fprintf(stdout, _( 251 | "Copyright (C) 2002-2006 CScience.ORG World Domination Inc.\n\n" 252 | "This program is Free Software; you can redistributed it\n" 253 | "and/or modify it under the terms of the GNU General Public\n" 254 | "License as published by the Free Software Foundation.\n\n" 255 | "%s version %s\n"), program_name, version); 256 | } 257 | exit (0); 258 | } 259 | 260 | int main(int argc, char **argv) 261 | { 262 | int c, ret = 0; 263 | int a = -1; 264 | const char *pathname = NULL; 265 | char *program_name = argv[0]; 266 | 267 | int show_help = 0; 268 | int show_version = 0; 269 | const char shortopts[] = "h:u:lf"; 270 | struct option longopts[] = { 271 | {"hide", 1, 0, 'h'}, 272 | {"unhide", 1, 0, 'u'}, 273 | {"list", 0, 0, 'l'}, 274 | {"flush", 0, 0, 'f'}, 275 | {"help", 0, &show_help, 1}, 276 | {"version", 0, &show_version, 1}, 277 | { 0, 0, 0, 0 } 278 | }; 279 | 280 | 281 | while ((c = getopt_long(argc, argv, shortopts, longopts, 0)) != -1) { 282 | switch (c) { 283 | case 'h': a = GOBOHIDE_CMD_HIDE; 284 | pathname = optarg; 285 | break; 286 | case 'u': a = GOBOHIDE_CMD_UNHIDE; 287 | pathname = optarg; 288 | break; 289 | case 'l': a = GOBOHIDE_CMD_LIST; 290 | break; 291 | case 'f': a = GOBOHIDE_CMD_FLUSH; 292 | break; 293 | } 294 | } 295 | 296 | setlocale(LC_ALL, ""); 297 | textdomain("gobohide"); 298 | bindtextdomain("gobohide", LOCALEDIR); 299 | 300 | if (show_help) 301 | usage(program_name, 1); 302 | if (show_version) 303 | usage(program_name, 0); 304 | 305 | /* Only the superuser is allowed to execute further */ 306 | if (getuid() != 0) { 307 | fprintf(stderr, _("Must be superuser\n")); 308 | exit(EXIT_SUCCESS); 309 | } 310 | 311 | init_netlink(); 312 | 313 | switch (a) { 314 | case -1: 315 | fprintf(stderr, _("%s: You must specify at least one option!\n\n" 316 | "try '%s --help' for more information\n"), program_name, program_name); 317 | break; 318 | 319 | case GOBOHIDE_CMD_LIST: 320 | ret = cmd_list(); 321 | break; 322 | 323 | case GOBOHIDE_CMD_FLUSH: 324 | ret = cmd_flush(); 325 | break; 326 | 327 | case GOBOHIDE_CMD_HIDE: 328 | case GOBOHIDE_CMD_UNHIDE: 329 | ret = cmd_hide_unhide((char *) pathname, a); 330 | while (ret == 0 && optind < argc) 331 | ret = cmd_hide_unhide(argv[optind++], a); 332 | } 333 | 334 | return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; 335 | } 336 | -------------------------------------------------------------------------------- /src/gobohide.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Use the following array to specify which directories to hide at boot time 3 | # 4 | 5 | UserDefinedEntries=( 6 | /bin 7 | /boot 8 | /dev 9 | /etc 10 | /lib 11 | /media 12 | /mnt 13 | /proc 14 | /sbin 15 | /srv 16 | /sys 17 | /tmp 18 | /usr 19 | /var 20 | ) 21 | -------------------------------------------------------------------------------- /src/gobohide.h: -------------------------------------------------------------------------------- 1 | #ifndef __GOBOHIDE_H 2 | #define __GOBOHIDE_H 3 | 4 | #define GOBOHIDE_GENL_NAME "gobohide" 5 | #define GOBOHIDE_GENL_VERSION 0x01 6 | 7 | /* netlink commands */ 8 | enum { 9 | GOBOHIDE_CMD_INVALID = 0, 10 | GOBOHIDE_CMD_HIDE, /* userspace -> kernel */ 11 | GOBOHIDE_CMD_UNHIDE, /* userspace -> kernel */ 12 | GOBOHIDE_CMD_FLUSH, /* userspace -> kernel */ 13 | GOBOHIDE_CMD_LIST, /* userspace -> kernel */ 14 | GOBOHIDE_CMD_LIST_SIZE, /* kernel -> userspace */ 15 | GOBOHIDE_CMD_LIST_REPLY, /* kernel -> userspace */ 16 | __GOBOHIDE_CMD_MAX 17 | }; 18 | #define GOBOHIDE_CMD_MAX (__GOBOHIDE_CMD_MAX - 1) 19 | 20 | /* netlink policies */ 21 | enum { 22 | GOBOHIDE_CMD_ATTR_UNSPEC = 0, 23 | GOBOHIDE_CMD_ATTR_PATH, 24 | GOBOHIDE_CMD_ATTR_INODE, 25 | __GOBOHIDE_CMD_ATTR_MAX, 26 | }; 27 | #define GOBOHIDE_CMD_ATTR_MAX (__GOBOHIDE_CMD_ATTR_MAX - 1) 28 | 29 | /* netlink data types (kernel -> userspace) */ 30 | enum { 31 | GOBOHIDE_TYPE_UNSPECT = 0, 32 | GOBOHIDE_TYPE_PATH, 33 | GOBOHIDE_TYPE_LIST_SIZE, 34 | __GOBOHIDE_TYPE_MAX, 35 | }; 36 | #define GOBOHIDE_TYPE_MAX (__GOBOHIDE_TYPE_MAX - 1) 37 | 38 | #endif /* __GOBOHIDE_H */ 39 | --------------------------------------------------------------------------------