diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c1f2077 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +# http://www.gnu.org/software/automake + +Makefile.in + +# http://www.gnu.org/software/autoconf + +/autom4te.cache +/aclocal.m4 +/compile +/configure +/depcomp +/install-sh +/missing +/stamp-h1 +/m4/* + +# files generated by configure +.deps +.libs +Makefile +config.h +libnsl.pc +*.o +*.lo +*.la +*.a +*~ +*.rej +*.orig +core +config.log +config.status +libnsl-*.tar.bz2 +libnsl-*.tar.gz +libtool +ltmain.sh +po/POTFILES +po/stamp-po +po/remove-potcdate.sed diff --git a/ABOUT-NLS b/ABOUT-NLS new file mode 100644 index 0000000..b1de1b6 --- /dev/null +++ b/ABOUT-NLS @@ -0,0 +1,1282 @@ +1 Notes on the Free Translation Project +*************************************** + +Free software is going international! The Free Translation Project is +a way to get maintainers of free software, translators, and users all +together, so that free software will gradually become able to speak many +languages. A few packages already provide translations for their +messages. + + If you found this `ABOUT-NLS' file inside a distribution, you may +assume that the distributed package does use GNU `gettext' internally, +itself available at your nearest GNU archive site. But you do _not_ +need to install GNU `gettext' prior to configuring, installing or using +this package with messages translated. + + Installers will find here some useful hints. These notes also +explain how users should proceed for getting the programs to use the +available translations. They tell how people wanting to contribute and +work on translations can contact the appropriate team. + +1.1 INSTALL Matters +=================== + +Some packages are "localizable" when properly installed; the programs +they contain can be made to speak your own native language. Most such +packages use GNU `gettext'. Other packages have their own ways to +internationalization, predating GNU `gettext'. + + By default, this package will be installed to allow translation of +messages. It will automatically detect whether the system already +provides the GNU `gettext' functions. Installers may use special +options at configuration time for changing the default behaviour. The +command: + + ./configure --disable-nls + +will _totally_ disable translation of messages. + + When you already have GNU `gettext' installed on your system and run +configure without an option for your new package, `configure' will +probably detect the previously built and installed `libintl' library +and will decide to use it. If not, you may have to to use the +`--with-libintl-prefix' option to tell `configure' where to look for it. + + Internationalized packages usually have many `po/LL.po' files, where +LL gives an ISO 639 two-letter code identifying the language. Unless +translations have been forbidden at `configure' time by using the +`--disable-nls' switch, all available translations are installed +together with the package. However, the environment variable `LINGUAS' +may be set, prior to configuration, to limit the installed set. +`LINGUAS' should then contain a space separated list of two-letter +codes, stating which languages are allowed. + +1.2 Using This Package +====================== + +As a user, if your language has been installed for this package, you +only have to set the `LANG' environment variable to the appropriate +`LL_CC' combination. If you happen to have the `LC_ALL' or some other +`LC_xxx' environment variables set, you should unset them before +setting `LANG', otherwise the setting of `LANG' will not have the +desired effect. Here `LL' is an ISO 639 two-letter language code, and +`CC' is an ISO 3166 two-letter country code. For example, let's +suppose that you speak German and live in Germany. At the shell +prompt, merely execute `setenv LANG de_DE' (in `csh'), +`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). +This can be done from your `.login' or `.profile' file, once and for +all. + + You might think that the country code specification is redundant. +But in fact, some languages have dialects in different countries. For +example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The +country code serves to distinguish the dialects. + + The locale naming convention of `LL_CC', with `LL' denoting the +language and `CC' denoting the country, is the one use on systems based +on GNU libc. On other systems, some variations of this scheme are +used, such as `LL' or `LL_CC.ENCODING'. You can get the list of +locales supported by your system for your language by running the +command `locale -a | grep '^LL''. + + Not all programs have translations for all languages. By default, an +English message is shown in place of a nonexistent translation. If you +understand other languages, you can set up a priority list of languages. +This is done through a different environment variable, called +`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' +for the purpose of message handling, but you still need to have `LANG' +set to the primary language; this is required by other parts of the +system libraries. For example, some Swedish users who would rather +read translations in German than English for when Swedish is not +available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. + + Special advice for Norwegian users: The language code for Norwegian +bokma*l changed from `no' to `nb' recently (in 2003). During the +transition period, while some message catalogs for this language are +installed under `nb' and some older ones under `no', it's recommended +for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and +older translations are used. + + In the `LANGUAGE' environment variable, but not in the `LANG' +environment variable, `LL_CC' combinations can be abbreviated as `LL' +to denote the language's main dialect. For example, `de' is equivalent +to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' +(Portuguese as spoken in Portugal) in this context. + +1.3 Translating Teams +===================== + +For the Free Translation Project to be a success, we need interested +people who like their own language and write it well, and who are also +able to synergize with other translators speaking the same language. +Each translation team has its own mailing list. The up-to-date list of +teams can be found at the Free Translation Project's homepage, +`http://translationproject.org/', in the "Teams" area. + + If you'd like to volunteer to _work_ at translating messages, you +should become a member of the translating team for your own language. +The subscribing address is _not_ the same as the list itself, it has +`-request' appended. For example, speakers of Swedish can send a +message to `sv-request@li.org', having this message body: + + subscribe + + Keep in mind that team members are expected to participate +_actively_ in translations, or at solving translational difficulties, +rather than merely lurking around. If your team does not exist yet and +you want to start one, or if you are unsure about what to do or how to +get started, please write to `coordinator@translationproject.org' to +reach the coordinator for all translator teams. + + The English team is special. It works at improving and uniformizing +the terminology in use. Proven linguistic skills are praised more than +programming skills, here. + +1.4 Available Packages +====================== + +Languages are not equally supported in all packages. The following +matrix shows the current state of internationalization, as of June +2010. The matrix shows, in regard of each package, for which languages +PO files have been submitted to translation coordination, with a +translation percentage of at least 50%. + + Ready PO files af am an ar as ast az be be@latin bg bn_IN bs ca + +--------------------------------------------------+ + a2ps | [] [] | + aegis | | + ant-phone | | + anubis | | + aspell | [] [] | + bash | | + bfd | | + bibshelf | [] | + binutils | | + bison | | + bison-runtime | [] | + bluez-pin | [] [] | + bombono-dvd | | + buzztard | | + cflow | | + clisp | | + coreutils | [] [] | + cpio | | + cppi | | + cpplib | [] | + cryptsetup | | + dfarc | | + dialog | [] [] | + dico | | + diffutils | [] | + dink | | + doodle | | + e2fsprogs | [] | + enscript | [] | + exif | | + fetchmail | [] | + findutils | [] | + flex | [] | + freedink | | + gas | | + gawk | [] [] | + gcal | [] | + gcc | | + gettext-examples | [] [] [] [] | + gettext-runtime | [] [] | + gettext-tools | [] [] | + gip | [] | + gjay | | + gliv | [] | + glunarclock | [] [] | + gnubiff | | + gnucash | [] | + gnuedu | | + gnulib | | + gnunet | | + gnunet-gtk | | + gnutls | | + gold | | + gpe-aerial | | + gpe-beam | | + gpe-bluetooth | | + gpe-calendar | | + gpe-clock | [] | + gpe-conf | | + gpe-contacts | | + gpe-edit | | + gpe-filemanager | | + gpe-go | | + gpe-login | | + gpe-ownerinfo | [] | + gpe-package | | + gpe-sketchbook | | + gpe-su | [] | + gpe-taskmanager | [] | + gpe-timesheet | [] | + gpe-today | [] | + gpe-todo | | + gphoto2 | | + gprof | [] | + gpsdrive | | + gramadoir | | + grep | | + grub | [] [] | + gsasl | | + gss | | + gst-plugins-bad | [] | + gst-plugins-base | [] | + gst-plugins-good | [] | + gst-plugins-ugly | [] | + gstreamer | [] [] [] | + gtick | | + gtkam | [] | + gtkorphan | [] | + gtkspell | [] [] [] | + gutenprint | | + hello | [] | + help2man | | + hylafax | | + idutils | | + indent | [] [] | + iso_15924 | | + iso_3166 | [] [] [] [] [] [] [] | + iso_3166_2 | | + iso_4217 | | + iso_639 | [] [] [] [] | + iso_639_3 | | + jwhois | | + kbd | | + keytouch | [] | + keytouch-editor | | + keytouch-keyboa... | [] | + klavaro | [] | + latrine | | + ld | [] | + leafpad | [] [] | + libc | [] [] | + libexif | () | + libextractor | | + libgnutls | | + libgpewidget | | + libgpg-error | | + libgphoto2 | | + libgphoto2_port | | + libgsasl | | + libiconv | [] | + libidn | | + lifelines | | + liferea | [] [] | + lilypond | | + linkdr | [] | + lordsawar | | + lprng | | + lynx | [] | + m4 | | + mailfromd | | + mailutils | | + make | | + man-db | | + man-db-manpages | | + minicom | | + mkisofs | | + myserver | | + nano | [] [] | + opcodes | | + parted | | + pies | | + popt | | + psmisc | | + pspp | [] | + pwdutils | | + radius | [] | + recode | [] [] | + rosegarden | | + rpm | | + rush | | + sarg | | + screem | | + scrollkeeper | [] [] [] | + sed | [] [] | + sharutils | [] [] | + shishi | | + skencil | | + solfege | | + solfege-manual | | + soundtracker | | + sp | | + sysstat | | + tar | [] | + texinfo | | + tin | | + unicode-han-tra... | | + unicode-transla... | | + util-linux-ng | [] | + vice | | + vmm | | + vorbis-tools | | + wastesedge | | + wdiff | | + wget | [] [] | + wyslij-po | | + xchat | [] [] [] [] | + xdg-user-dirs | [] [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] | + +--------------------------------------------------+ + af am an ar as ast az be be@latin bg bn_IN bs ca + 6 0 1 2 3 19 1 10 3 28 3 1 38 + + crh cs da de el en en_GB en_ZA eo es et eu fa + +-------------------------------------------------+ + a2ps | [] [] [] [] [] [] [] | + aegis | [] [] [] | + ant-phone | [] () | + anubis | [] [] | + aspell | [] [] [] [] [] | + bash | [] [] [] | + bfd | [] | + bibshelf | [] [] [] | + binutils | [] | + bison | [] [] | + bison-runtime | [] [] [] [] | + bluez-pin | [] [] [] [] [] [] | + bombono-dvd | [] | + buzztard | [] [] [] | + cflow | [] [] | + clisp | [] [] [] [] | + coreutils | [] [] [] [] | + cpio | | + cppi | | + cpplib | [] [] [] | + cryptsetup | [] | + dfarc | [] [] [] | + dialog | [] [] [] [] [] | + dico | | + diffutils | [] [] [] [] [] [] | + dink | [] [] [] | + doodle | [] | + e2fsprogs | [] [] [] | + enscript | [] [] [] | + exif | () [] [] | + fetchmail | [] [] () [] [] [] | + findutils | [] [] [] | + flex | [] [] | + freedink | [] [] [] | + gas | [] | + gawk | [] [] [] | + gcal | [] | + gcc | [] [] | + gettext-examples | [] [] [] [] | + gettext-runtime | [] [] [] [] | + gettext-tools | [] [] [] | + gip | [] [] [] [] | + gjay | [] | + gliv | [] [] [] | + glunarclock | [] [] | + gnubiff | () | + gnucash | [] () () () () | + gnuedu | [] [] | + gnulib | [] [] | + gnunet | | + gnunet-gtk | [] | + gnutls | [] [] | + gold | [] | + gpe-aerial | [] [] [] [] | + gpe-beam | [] [] [] [] | + gpe-bluetooth | [] [] | + gpe-calendar | [] | + gpe-clock | [] [] [] [] | + gpe-conf | [] [] [] | + gpe-contacts | [] [] [] | + gpe-edit | [] [] | + gpe-filemanager | [] [] [] | + gpe-go | [] [] [] [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] [] [] | + gpe-package | [] [] [] | + gpe-sketchbook | [] [] [] [] | + gpe-su | [] [] [] [] | + gpe-taskmanager | [] [] [] [] | + gpe-timesheet | [] [] [] [] | + gpe-today | [] [] [] [] | + gpe-todo | [] [] [] | + gphoto2 | [] [] () [] [] [] | + gprof | [] [] [] | + gpsdrive | [] [] [] | + gramadoir | [] [] [] | + grep | [] | + grub | [] [] | + gsasl | [] | + gss | | + gst-plugins-bad | [] [] [] [] [] | + gst-plugins-base | [] [] [] [] [] | + gst-plugins-good | [] [] [] [] [] [] | + gst-plugins-ugly | [] [] [] [] [] [] | + gstreamer | [] [] [] [] [] | + gtick | [] () [] | + gtkam | [] [] () [] [] | + gtkorphan | [] [] [] [] | + gtkspell | [] [] [] [] [] [] [] | + gutenprint | [] [] [] | + hello | [] [] [] [] | + help2man | [] | + hylafax | [] [] | + idutils | [] [] | + indent | [] [] [] [] [] [] [] | + iso_15924 | [] () [] [] | + iso_3166 | [] [] [] [] () [] [] [] () | + iso_3166_2 | () | + iso_4217 | [] [] [] () [] [] | + iso_639 | [] [] [] [] () [] [] | + iso_639_3 | [] | + jwhois | [] | + kbd | [] [] [] [] [] | + keytouch | [] [] | + keytouch-editor | [] [] | + keytouch-keyboa... | [] | + klavaro | [] [] [] [] | + latrine | [] () | + ld | [] [] | + leafpad | [] [] [] [] [] [] | + libc | [] [] [] [] | + libexif | [] [] () | + libextractor | | + libgnutls | [] | + libgpewidget | [] [] | + libgpg-error | [] [] | + libgphoto2 | [] () | + libgphoto2_port | [] () [] | + libgsasl | | + libiconv | [] [] [] [] [] | + libidn | [] [] [] | + lifelines | [] () | + liferea | [] [] [] [] [] | + lilypond | [] [] [] | + linkdr | [] [] [] | + lordsawar | [] | + lprng | | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailfromd | | + mailutils | [] | + make | [] [] [] | + man-db | | + man-db-manpages | | + minicom | [] [] [] [] | + mkisofs | | + myserver | | + nano | [] [] [] | + opcodes | [] [] | + parted | [] [] | + pies | | + popt | [] [] [] [] [] | + psmisc | [] [] [] | + pspp | [] | + pwdutils | [] | + radius | [] | + recode | [] [] [] [] [] [] | + rosegarden | () () () | + rpm | [] [] [] | + rush | | + sarg | | + screem | | + scrollkeeper | [] [] [] [] [] | + sed | [] [] [] [] [] [] | + sharutils | [] [] [] [] | + shishi | | + skencil | [] () [] | + solfege | [] [] [] | + solfege-manual | [] [] | + soundtracker | [] [] [] | + sp | [] | + sysstat | [] [] [] | + tar | [] [] [] [] | + texinfo | [] [] [] | + tin | [] [] | + unicode-han-tra... | | + unicode-transla... | | + util-linux-ng | [] [] [] [] | + vice | () () | + vmm | [] | + vorbis-tools | [] [] | + wastesedge | [] | + wdiff | [] [] | + wget | [] [] [] | + wyslij-po | | + xchat | [] [] [] [] [] | + xdg-user-dirs | [] [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] [] [] [] | + +-------------------------------------------------+ + crh cs da de el en en_GB en_ZA eo es et eu fa + 5 64 105 117 18 1 8 0 28 89 18 19 0 + + fi fr ga gl gu he hi hr hu hy id is it ja ka kn + +----------------------------------------------------+ + a2ps | [] [] [] [] | + aegis | [] [] | + ant-phone | [] [] | + anubis | [] [] [] [] | + aspell | [] [] [] [] | + bash | [] [] [] [] | + bfd | [] [] [] | + bibshelf | [] [] [] [] [] | + binutils | [] [] [] | + bison | [] [] [] [] | + bison-runtime | [] [] [] [] [] [] | + bluez-pin | [] [] [] [] [] [] [] [] | + bombono-dvd | [] | + buzztard | [] | + cflow | [] [] [] | + clisp | [] | + coreutils | [] [] [] [] [] | + cpio | [] [] [] [] | + cppi | [] [] | + cpplib | [] [] [] | + cryptsetup | [] [] [] | + dfarc | [] [] [] | + dialog | [] [] [] [] [] [] [] | + dico | | + diffutils | [] [] [] [] [] [] [] [] [] | + dink | [] | + doodle | [] [] | + e2fsprogs | [] [] | + enscript | [] [] [] [] | + exif | [] [] [] [] [] [] | + fetchmail | [] [] [] [] | + findutils | [] [] [] [] [] [] | + flex | [] [] [] | + freedink | [] [] [] | + gas | [] [] | + gawk | [] [] [] [] () [] | + gcal | [] | + gcc | [] | + gettext-examples | [] [] [] [] [] [] [] | + gettext-runtime | [] [] [] [] [] [] | + gettext-tools | [] [] [] [] | + gip | [] [] [] [] [] [] | + gjay | [] | + gliv | [] () | + glunarclock | [] [] [] [] | + gnubiff | () [] () | + gnucash | () () () () () [] | + gnuedu | [] [] | + gnulib | [] [] [] [] [] [] | + gnunet | | + gnunet-gtk | [] | + gnutls | [] [] | + gold | [] [] | + gpe-aerial | [] [] [] | + gpe-beam | [] [] [] [] | + gpe-bluetooth | [] [] [] [] | + gpe-calendar | [] [] | + gpe-clock | [] [] [] [] [] | + gpe-conf | [] [] [] [] | + gpe-contacts | [] [] [] [] | + gpe-edit | [] [] [] | + gpe-filemanager | [] [] [] [] | + gpe-go | [] [] [] [] [] | + gpe-login | [] [] [] | + gpe-ownerinfo | [] [] [] [] [] | + gpe-package | [] [] [] | + gpe-sketchbook | [] [] [] [] | + gpe-su | [] [] [] [] [] [] | + gpe-taskmanager | [] [] [] [] [] | + gpe-timesheet | [] [] [] [] [] | + gpe-today | [] [] [] [] [] [] [] | + gpe-todo | [] [] [] | + gphoto2 | [] [] [] [] [] [] | + gprof | [] [] [] [] | + gpsdrive | [] [] [] | + gramadoir | [] [] [] | + grep | [] [] | + grub | [] [] [] [] | + gsasl | [] [] [] [] [] | + gss | [] [] [] [] [] | + gst-plugins-bad | [] [] [] [] [] [] | + gst-plugins-base | [] [] [] [] [] [] | + gst-plugins-good | [] [] [] [] [] [] | + gst-plugins-ugly | [] [] [] [] [] [] | + gstreamer | [] [] [] [] [] | + gtick | [] [] [] [] [] | + gtkam | [] [] [] [] [] | + gtkorphan | [] [] [] | + gtkspell | [] [] [] [] [] [] [] [] [] | + gutenprint | [] [] [] [] | + hello | [] [] [] | + help2man | [] [] | + hylafax | [] | + idutils | [] [] [] [] [] [] | + indent | [] [] [] [] [] [] [] [] | + iso_15924 | [] () [] [] | + iso_3166 | [] () [] [] [] [] [] [] [] [] [] [] | + iso_3166_2 | () [] [] [] | + iso_4217 | [] () [] [] [] [] | + iso_639 | [] () [] [] [] [] [] [] [] | + iso_639_3 | () [] [] | + jwhois | [] [] [] [] [] | + kbd | [] [] | + keytouch | [] [] [] [] [] [] | + keytouch-editor | [] [] [] [] [] | + keytouch-keyboa... | [] [] [] [] [] | + klavaro | [] [] | + latrine | [] [] [] | + ld | [] [] [] [] | + leafpad | [] [] [] [] [] [] [] () | + libc | [] [] [] [] [] | + libexif | [] | + libextractor | | + libgnutls | [] [] | + libgpewidget | [] [] [] [] | + libgpg-error | [] [] | + libgphoto2 | [] [] [] | + libgphoto2_port | [] [] [] | + libgsasl | [] [] [] [] [] | + libiconv | [] [] [] [] [] [] | + libidn | [] [] [] [] | + lifelines | () | + liferea | [] [] [] [] | + lilypond | [] [] | + linkdr | [] [] [] [] [] | + lordsawar | | + lprng | [] | + lynx | [] [] [] [] [] | + m4 | [] [] [] [] [] [] | + mailfromd | | + mailutils | [] [] | + make | [] [] [] [] [] [] [] [] [] | + man-db | [] [] | + man-db-manpages | [] | + minicom | [] [] [] [] [] | + mkisofs | [] [] [] [] | + myserver | | + nano | [] [] [] [] [] [] | + opcodes | [] [] [] [] | + parted | [] [] [] [] | + pies | | + popt | [] [] [] [] [] [] [] [] [] | + psmisc | [] [] [] | + pspp | | + pwdutils | [] [] | + radius | [] [] | + recode | [] [] [] [] [] [] [] [] | + rosegarden | () () () () () | + rpm | [] [] | + rush | | + sarg | [] | + screem | [] [] | + scrollkeeper | [] [] [] [] | + sed | [] [] [] [] [] [] [] [] | + sharutils | [] [] [] [] [] [] [] | + shishi | [] | + skencil | [] | + solfege | [] [] [] [] | + solfege-manual | [] [] | + soundtracker | [] [] | + sp | [] () | + sysstat | [] [] [] [] [] | + tar | [] [] [] [] [] [] [] | + texinfo | [] [] [] [] | + tin | [] | + unicode-han-tra... | | + unicode-transla... | [] [] | + util-linux-ng | [] [] [] [] [] [] | + vice | () () () | + vmm | [] | + vorbis-tools | [] | + wastesedge | () () | + wdiff | [] | + wget | [] [] [] [] [] [] [] [] | + wyslij-po | [] [] [] | + xchat | [] [] [] [] [] [] [] [] [] | + xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] [] [] | + +----------------------------------------------------+ + fi fr ga gl gu he hi hr hu hy id is it ja ka kn + 105 121 53 20 4 8 3 5 53 2 120 5 84 67 0 4 + + ko ku ky lg lt lv mk ml mn mr ms mt nb nds ne + +-----------------------------------------------+ + a2ps | [] | + aegis | | + ant-phone | | + anubis | [] [] | + aspell | [] | + bash | | + bfd | | + bibshelf | [] [] | + binutils | | + bison | [] | + bison-runtime | [] [] [] [] [] | + bluez-pin | [] [] [] [] [] | + bombono-dvd | | + buzztard | | + cflow | | + clisp | | + coreutils | [] | + cpio | | + cppi | | + cpplib | | + cryptsetup | | + dfarc | [] | + dialog | [] [] [] [] [] | + dico | | + diffutils | [] [] | + dink | | + doodle | | + e2fsprogs | | + enscript | | + exif | [] | + fetchmail | | + findutils | | + flex | | + freedink | [] | + gas | | + gawk | | + gcal | | + gcc | | + gettext-examples | [] [] [] [] | + gettext-runtime | [] | + gettext-tools | [] | + gip | [] [] | + gjay | | + gliv | | + glunarclock | [] | + gnubiff | | + gnucash | () () () () | + gnuedu | | + gnulib | | + gnunet | | + gnunet-gtk | | + gnutls | [] | + gold | | + gpe-aerial | [] | + gpe-beam | [] | + gpe-bluetooth | [] [] | + gpe-calendar | [] | + gpe-clock | [] [] [] [] [] | + gpe-conf | [] [] | + gpe-contacts | [] [] | + gpe-edit | [] | + gpe-filemanager | [] [] | + gpe-go | [] [] [] | + gpe-login | [] | + gpe-ownerinfo | [] [] | + gpe-package | [] [] | + gpe-sketchbook | [] [] | + gpe-su | [] [] [] [] [] [] | + gpe-taskmanager | [] [] [] [] [] [] | + gpe-timesheet | [] [] | + gpe-today | [] [] [] [] | + gpe-todo | [] [] | + gphoto2 | | + gprof | [] | + gpsdrive | | + gramadoir | | + grep | | + grub | | + gsasl | | + gss | | + gst-plugins-bad | [] [] [] [] | + gst-plugins-base | [] [] | + gst-plugins-good | [] [] | + gst-plugins-ugly | [] [] [] [] [] | + gstreamer | | + gtick | | + gtkam | [] | + gtkorphan | [] [] | + gtkspell | [] [] [] [] [] [] [] | + gutenprint | | + hello | [] [] [] | + help2man | | + hylafax | | + idutils | | + indent | | + iso_15924 | [] [] | + iso_3166 | [] [] () [] [] [] [] [] | + iso_3166_2 | | + iso_4217 | [] [] | + iso_639 | [] [] | + iso_639_3 | [] | + jwhois | [] | + kbd | | + keytouch | [] | + keytouch-editor | [] | + keytouch-keyboa... | [] | + klavaro | [] | + latrine | [] | + ld | | + leafpad | [] [] [] | + libc | [] | + libexif | | + libextractor | | + libgnutls | [] | + libgpewidget | [] [] | + libgpg-error | | + libgphoto2 | | + libgphoto2_port | | + libgsasl | | + libiconv | | + libidn | | + lifelines | | + liferea | | + lilypond | | + linkdr | | + lordsawar | | + lprng | | + lynx | | + m4 | | + mailfromd | | + mailutils | | + make | [] | + man-db | | + man-db-manpages | | + minicom | [] | + mkisofs | | + myserver | | + nano | [] [] | + opcodes | | + parted | | + pies | | + popt | [] [] [] | + psmisc | | + pspp | | + pwdutils | | + radius | | + recode | | + rosegarden | | + rpm | | + rush | | + sarg | | + screem | | + scrollkeeper | [] [] | + sed | | + sharutils | | + shishi | | + skencil | | + solfege | [] | + solfege-manual | | + soundtracker | | + sp | | + sysstat | [] | + tar | [] | + texinfo | [] | + tin | | + unicode-han-tra... | | + unicode-transla... | | + util-linux-ng | | + vice | | + vmm | | + vorbis-tools | | + wastesedge | | + wdiff | | + wget | [] | + wyslij-po | | + xchat | [] [] [] | + xdg-user-dirs | [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] | + +-----------------------------------------------+ + ko ku ky lg lt lv mk ml mn mr ms mt nb nds ne + 20 5 10 1 13 48 4 2 2 4 24 10 20 3 1 + + nl nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr + +---------------------------------------------------+ + a2ps | [] [] [] [] [] [] [] [] | + aegis | [] [] [] | + ant-phone | [] [] | + anubis | [] [] [] | + aspell | [] [] [] [] [] | + bash | [] [] | + bfd | [] | + bibshelf | [] [] | + binutils | [] [] | + bison | [] [] [] | + bison-runtime | [] [] [] [] [] [] [] | + bluez-pin | [] [] [] [] [] [] [] [] | + bombono-dvd | [] () | + buzztard | [] [] | + cflow | [] | + clisp | [] [] | + coreutils | [] [] [] [] [] [] | + cpio | [] [] [] | + cppi | [] | + cpplib | [] | + cryptsetup | [] | + dfarc | [] | + dialog | [] [] [] [] | + dico | [] | + diffutils | [] [] [] [] [] [] | + dink | () | + doodle | [] [] | + e2fsprogs | [] [] | + enscript | [] [] [] [] [] | + exif | [] [] [] () [] | + fetchmail | [] [] [] [] | + findutils | [] [] [] [] [] | + flex | [] [] [] [] [] | + freedink | [] [] | + gas | | + gawk | [] [] [] [] | + gcal | | + gcc | [] | + gettext-examples | [] [] [] [] [] [] [] [] | + gettext-runtime | [] [] [] [] [] [] [] [] [] | + gettext-tools | [] [] [] [] [] [] | + gip | [] [] [] [] [] | + gjay | | + gliv | [] [] [] [] [] [] | + glunarclock | [] [] [] [] [] | + gnubiff | [] () | + gnucash | [] () () () | + gnuedu | [] | + gnulib | [] [] [] [] | + gnunet | | + gnunet-gtk | | + gnutls | [] [] | + gold | | + gpe-aerial | [] [] [] [] [] [] [] | + gpe-beam | [] [] [] [] [] [] [] | + gpe-bluetooth | [] [] | + gpe-calendar | [] [] [] [] | + gpe-clock | [] [] [] [] [] [] [] [] | + gpe-conf | [] [] [] [] [] [] [] | + gpe-contacts | [] [] [] [] [] | + gpe-edit | [] [] [] | + gpe-filemanager | [] [] [] | + gpe-go | [] [] [] [] [] [] [] [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] [] [] [] [] [] [] | + gpe-package | [] [] | + gpe-sketchbook | [] [] [] [] [] [] [] | + gpe-su | [] [] [] [] [] [] [] [] | + gpe-taskmanager | [] [] [] [] [] [] [] [] | + gpe-timesheet | [] [] [] [] [] [] [] [] | + gpe-today | [] [] [] [] [] [] [] [] | + gpe-todo | [] [] [] [] [] | + gphoto2 | [] [] [] [] [] [] [] [] | + gprof | [] [] [] | + gpsdrive | [] [] | + gramadoir | [] [] | + grep | [] [] [] [] | + grub | [] [] [] | + gsasl | [] [] [] [] | + gss | [] [] [] | + gst-plugins-bad | [] [] [] [] [] [] | + gst-plugins-base | [] [] [] [] [] | + gst-plugins-good | [] [] [] [] [] | + gst-plugins-ugly | [] [] [] [] [] [] | + gstreamer | [] [] [] [] [] | + gtick | [] [] [] | + gtkam | [] [] [] [] [] [] | + gtkorphan | [] | + gtkspell | [] [] [] [] [] [] [] [] [] [] | + gutenprint | [] [] | + hello | [] [] [] [] | + help2man | [] [] | + hylafax | [] | + idutils | [] [] [] [] [] | + indent | [] [] [] [] [] [] [] | + iso_15924 | [] [] [] [] | + iso_3166 | [] [] [] [] [] () [] [] [] [] [] [] [] [] | + iso_3166_2 | [] [] [] | + iso_4217 | [] [] [] [] [] [] [] [] | + iso_639 | [] [] [] [] [] [] [] [] [] | + iso_639_3 | [] [] | + jwhois | [] [] [] [] | + kbd | [] [] [] | + keytouch | [] [] [] | + keytouch-editor | [] [] [] | + keytouch-keyboa... | [] [] [] | + klavaro | [] [] | + latrine | [] [] | + ld | | + leafpad | [] [] [] [] [] [] [] [] [] | + libc | [] [] [] [] | + libexif | [] [] () [] | + libextractor | | + libgnutls | [] [] | + libgpewidget | [] [] [] | + libgpg-error | [] [] | + libgphoto2 | [] [] | + libgphoto2_port | [] [] [] [] [] | + libgsasl | [] [] [] [] [] | + libiconv | [] [] [] [] [] | + libidn | [] [] | + lifelines | [] [] | + liferea | [] [] [] [] [] () () [] | + lilypond | [] | + linkdr | [] [] [] | + lordsawar | | + lprng | [] | + lynx | [] [] [] | + m4 | [] [] [] [] [] | + mailfromd | [] | + mailutils | [] | + make | [] [] [] [] | + man-db | [] [] [] | + man-db-manpages | [] [] [] | + minicom | [] [] [] [] | + mkisofs | [] [] [] | + myserver | | + nano | [] [] [] [] | + opcodes | [] [] | + parted | [] [] [] [] | + pies | [] | + popt | [] [] [] [] | + psmisc | [] [] [] | + pspp | [] [] | + pwdutils | [] | + radius | [] [] [] | + recode | [] [] [] [] [] [] [] [] | + rosegarden | () () | + rpm | [] [] [] | + rush | [] [] | + sarg | | + screem | | + scrollkeeper | [] [] [] [] [] [] [] [] | + sed | [] [] [] [] [] [] [] [] [] | + sharutils | [] [] [] [] | + shishi | [] | + skencil | [] [] | + solfege | [] [] [] [] | + solfege-manual | [] [] [] | + soundtracker | [] | + sp | | + sysstat | [] [] [] [] | + tar | [] [] [] [] | + texinfo | [] [] [] [] | + tin | [] | + unicode-han-tra... | | + unicode-transla... | | + util-linux-ng | [] [] [] [] [] | + vice | [] | + vmm | [] | + vorbis-tools | [] [] | + wastesedge | [] | + wdiff | [] [] | + wget | [] [] [] [] [] [] [] | + wyslij-po | [] [] [] | + xchat | [] [] [] [] [] [] [] [] [] | + xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] | + +---------------------------------------------------+ + nl nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr + 135 10 4 7 105 1 29 62 47 91 3 54 46 9 37 + + sv sw ta te tg th tr uk vi wa zh_CN zh_HK zh_TW + +---------------------------------------------------+ + a2ps | [] [] [] [] [] | 27 + aegis | [] | 9 + ant-phone | [] [] [] [] | 9 + anubis | [] [] [] [] | 15 + aspell | [] [] [] | 20 + bash | [] [] [] | 12 + bfd | [] | 6 + bibshelf | [] [] [] | 16 + binutils | [] [] | 8 + bison | [] [] | 12 + bison-runtime | [] [] [] [] [] [] | 29 + bluez-pin | [] [] [] [] [] [] [] [] | 37 + bombono-dvd | [] | 4 + buzztard | [] | 7 + cflow | [] [] [] | 9 + clisp | | 10 + coreutils | [] [] [] [] | 22 + cpio | [] [] [] [] [] [] | 13 + cppi | [] [] | 5 + cpplib | [] [] [] [] [] [] | 14 + cryptsetup | [] [] | 7 + dfarc | [] | 9 + dialog | [] [] [] [] [] [] [] | 30 + dico | [] | 2 + diffutils | [] [] [] [] [] [] | 30 + dink | | 4 + doodle | [] [] | 7 + e2fsprogs | [] [] [] | 11 + enscript | [] [] [] [] | 17 + exif | [] [] [] | 16 + fetchmail | [] [] [] | 17 + findutils | [] [] [] [] [] | 20 + flex | [] [] [] [] | 15 + freedink | [] | 10 + gas | [] | 4 + gawk | [] [] [] [] | 18 + gcal | [] [] | 5 + gcc | [] [] [] | 7 + gettext-examples | [] [] [] [] [] [] [] | 34 + gettext-runtime | [] [] [] [] [] [] [] | 29 + gettext-tools | [] [] [] [] [] [] | 22 + gip | [] [] [] [] | 22 + gjay | [] | 3 + gliv | [] [] [] | 14 + glunarclock | [] [] [] [] [] | 19 + gnubiff | [] [] | 4 + gnucash | () [] () [] () | 10 + gnuedu | [] [] | 7 + gnulib | [] [] [] [] | 16 + gnunet | [] | 1 + gnunet-gtk | [] [] [] | 5 + gnutls | [] [] [] | 10 + gold | [] | 4 + gpe-aerial | [] [] [] | 18 + gpe-beam | [] [] [] | 19 + gpe-bluetooth | [] [] [] | 13 + gpe-calendar | [] [] [] [] | 12 + gpe-clock | [] [] [] [] [] | 28 + gpe-conf | [] [] [] [] | 20 + gpe-contacts | [] [] [] | 17 + gpe-edit | [] [] [] | 12 + gpe-filemanager | [] [] [] [] | 16 + gpe-go | [] [] [] [] [] | 25 + gpe-login | [] [] [] | 11 + gpe-ownerinfo | [] [] [] [] [] | 25 + gpe-package | [] [] [] | 13 + gpe-sketchbook | [] [] [] | 20 + gpe-su | [] [] [] [] [] | 30 + gpe-taskmanager | [] [] [] [] [] | 29 + gpe-timesheet | [] [] [] [] [] | 25 + gpe-today | [] [] [] [] [] [] | 30 + gpe-todo | [] [] [] [] | 17 + gphoto2 | [] [] [] [] [] | 24 + gprof | [] [] [] | 15 + gpsdrive | [] [] [] | 11 + gramadoir | [] [] [] | 11 + grep | [] [] [] | 10 + grub | [] [] [] | 14 + gsasl | [] [] [] [] | 14 + gss | [] [] [] | 11 + gst-plugins-bad | [] [] [] [] | 26 + gst-plugins-base | [] [] [] [] [] | 24 + gst-plugins-good | [] [] [] [] | 24 + gst-plugins-ugly | [] [] [] [] [] | 29 + gstreamer | [] [] [] [] | 22 + gtick | [] [] [] | 13 + gtkam | [] [] [] | 20 + gtkorphan | [] [] [] | 14 + gtkspell | [] [] [] [] [] [] [] [] [] | 45 + gutenprint | [] | 10 + hello | [] [] [] [] [] [] | 21 + help2man | [] [] | 7 + hylafax | [] | 5 + idutils | [] [] [] [] | 17 + indent | [] [] [] [] [] [] | 30 + iso_15924 | () [] () [] [] | 16 + iso_3166 | [] [] () [] [] () [] [] [] () | 53 + iso_3166_2 | () [] () [] | 9 + iso_4217 | [] () [] [] () [] [] | 26 + iso_639 | [] [] [] () [] () [] [] [] [] | 38 + iso_639_3 | [] () | 8 + jwhois | [] [] [] [] [] | 16 + kbd | [] [] [] [] [] | 15 + keytouch | [] [] [] | 16 + keytouch-editor | [] [] [] | 14 + keytouch-keyboa... | [] [] [] | 14 + klavaro | [] | 11 + latrine | [] [] [] | 10 + ld | [] [] [] [] | 11 + leafpad | [] [] [] [] [] [] | 33 + libc | [] [] [] [] [] | 21 + libexif | [] () | 7 + libextractor | [] | 1 + libgnutls | [] [] [] | 9 + libgpewidget | [] [] [] | 14 + libgpg-error | [] [] [] | 9 + libgphoto2 | [] [] | 8 + libgphoto2_port | [] [] [] [] | 14 + libgsasl | [] [] [] | 13 + libiconv | [] [] [] [] | 21 + libidn | () [] [] | 11 + lifelines | [] | 4 + liferea | [] [] [] | 21 + lilypond | [] | 7 + linkdr | [] [] [] [] [] | 17 + lordsawar | | 1 + lprng | [] | 3 + lynx | [] [] [] [] | 17 + m4 | [] [] [] [] | 19 + mailfromd | [] [] | 3 + mailutils | [] | 5 + make | [] [] [] [] | 21 + man-db | [] [] [] | 8 + man-db-manpages | | 4 + minicom | [] [] | 16 + mkisofs | [] [] | 9 + myserver | | 0 + nano | [] [] [] [] | 21 + opcodes | [] [] [] | 11 + parted | [] [] [] [] [] | 15 + pies | [] [] | 3 + popt | [] [] [] [] [] [] | 27 + psmisc | [] [] | 11 + pspp | | 4 + pwdutils | [] [] | 6 + radius | [] [] | 9 + recode | [] [] [] [] | 28 + rosegarden | () | 0 + rpm | [] [] [] | 11 + rush | [] [] | 4 + sarg | | 1 + screem | [] | 3 + scrollkeeper | [] [] [] [] [] | 27 + sed | [] [] [] [] [] | 30 + sharutils | [] [] [] [] [] | 22 + shishi | [] | 3 + skencil | [] [] | 7 + solfege | [] [] [] [] | 16 + solfege-manual | [] | 8 + soundtracker | [] [] [] | 9 + sp | [] | 3 + sysstat | [] [] | 15 + tar | [] [] [] [] [] [] | 23 + texinfo | [] [] [] [] [] | 17 + tin | | 4 + unicode-han-tra... | | 0 + unicode-transla... | | 2 + util-linux-ng | [] [] [] [] | 20 + vice | () () | 1 + vmm | [] | 4 + vorbis-tools | [] | 6 + wastesedge | | 2 + wdiff | [] [] | 7 + wget | [] [] [] [] [] | 26 + wyslij-po | [] [] | 8 + xchat | [] [] [] [] [] [] | 36 + xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] | 63 + xkeyboard-config | [] [] [] | 22 + +---------------------------------------------------+ + 85 teams sv sw ta te tg th tr uk vi wa zh_CN zh_HK zh_TW + 178 domains 119 1 3 3 0 10 65 51 155 17 98 7 41 2618 + + Some counters in the preceding matrix are higher than the number of +visible blocks let us expect. This is because a few extra PO files are +used for implementing regional variants of languages, or language +dialects. + + For a PO file in the matrix above to be effective, the package to +which it applies should also have been internationalized and +distributed as such by its maintainer. There might be an observable +lag between the mere existence a PO file and its wide availability in a +distribution. + + If June 2010 seems to be old, you may fetch a more recent copy of +this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date +matrix with full percentage details can be found at +`http://translationproject.org/extra/matrix.html'. + +1.5 Using `gettext' in new packages +=================================== + +If you are writing a freely available program and want to +internationalize it you are welcome to use GNU `gettext' in your +package. Of course you have to respect the GNU Library General Public +License which covers the use of the GNU `gettext' library. This means +in particular that even non-free programs can use `libintl' as a shared +library, whereas only free software can use `libintl' as a static +library or use modified versions of `libintl'. + + Once the sources are changed appropriately and the setup can handle +the use of `gettext' the only thing missing are the translations. The +Free Translation Project is also available for packages which are not +developed inside the GNU project. Therefore the information given above +applies also for every other Free Software Project. Contact +`coordinator@translationproject.org' to make the `.pot' files available +to the translation teams. + diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/AUTHORS diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..4362b49 --- /dev/null +++ b/COPYING @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..d5f7217 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,124 @@ +2017-02-23 Thorsten Kukuk + + * release version 1.0.5 + + * src/nisplus/nis_call.c (nis_server_cache_add): Add explicit braces. + + * src/do_ypcall.c: Remove unused static variable UDPTIMEOUT. + +2016-03-08 Thorsten Kukuk + + * release version 1.0.4 + + * src/rpcsvc/yppasswd.h: define own struct passwd to be + compatible with glibc implementation. + +2016-02-17 Thorsten Kukuk + + * release version 1.0.3 + + * src/nisplus/nis_table.c: Remove static from some functions, + we want to export them for libnss_nisplus plugin. + + * src/libnsl.map: Export some functions as LIBNSL_PRIVATE for the + libnss_nisplus plugin. + +2016-02-15 Thorsten Kukuk + + * release version 1.0.2 + + * src/rpcsvc/yppasswd.h: New. + * src/rpcsvc/yppasswd.x: New. + * src/taddr2host.c: New. + * src/taddr2port.c: New. + + * src/Makefile.am: Add new files. + * src/libnsl.map: Export taddr2host, taddr2ipstr, taddr2port. + * src/rpcsvc/yp_prot.h: Remove__*ypbind3_binding* prototypes. + + * src/nisplus/nis_findserv.c: Don't use __libc_rpc_getport. + +2016-01-20 Thorsten Kukuk + + * release version 1.0.1 + + * src/yp_xdr.c (xdr_keydat): Make public. + * src/yp_xdr.c (xdr_valdat): Likewise. + * src/yp_xdr.c (xdr_ypcall): Likewise. + * src/libnsl.map: Add new public functions. + * src/rpcsvc/yp_prot.h: Add prototypes for xdr_keydat and xdr_valdat. + + * src/nisplus/nis_callback.c: Enable all code for TIRPC. + + * src/do_ypcall.c: Change resp argument of do_ypcall_tr from + caddr_t to ypresp_val. + * src/internal.h: Likewise. + * src/yp_maplist.c: Adjust call of do_ypcall_tr. + * src/yp_master.c: Likewise. + * src/yp_match.c: Likewise. + * src/yp_next.c: Likewise. + * src/yp_order.c: Likewise. + Based on patch by Jonathan Ben Avraham + +2015-07-09 Thorsten Kukuk + + * src/yp_xdr.c: Include config.h + * src/do_ypcall.c: Disable ypbind3 support for SunRPC + +2015-07-08 Thorsten Kukuk + + * configure.ac: Check for tirpc or sunrpc + * src/do_ypcall.c: Adjust code to compile with tirpc and sunrpc + * src/nisplus/nis_callback.c: Likewise. + * src/nisplus/nis_domain_of.c: Likewise. + * src/nisplus/nis_findserv.c: Likewise. + * src/nisplus/nis_subr.c: Likewise. + * src/nisplus/nis_table.c: Likewise. + * src/nisplus/nis_util.c: Likewise. + * src/taddr2ipstr.c: Likewise. + * src/yp_xdr.c: Likewise. + +2015-06-27 Thorsten Kukuk + + * src/nisplus/nis_add.c: Adjust includes. + * src/nisplus/nis_addmember.c: Likewise. + * src/nisplus/nis_callback.c: Likewise. + * src/nisplus/nis_checkpoint.c: Likewise. + * src/nisplus/nis_clone_dir.c: Likewise. + * src/nisplus/nis_clone_obj.c: Likewise. + * src/nisplus/nis_defaults.c: Likewise. + * src/nisplus/nis_destroygroup.c: Likewise. + * src/nisplus/nis_domain_of.c: Likewise. + * src/nisplus/nis_domain_of_r.c: Likewise. + * src/nisplus/nis_file.c: Likewise. + * src/nisplus/nis_findserv.c: Likewise. + * src/nisplus/nis_free.c: Likewise. + * src/nisplus/nis_getservlist.c: Likewise. + * src/nisplus/nis_ismember.c: Likewise. + * src/nisplus/nis_local_names.c: Likewise. + * src/nisplus/nis_lookup.c: Likewise. + * src/nisplus/nis_mkdir.c: Likewise. + * src/nisplus/nis_modify.c: Likewise. + * src/nisplus/nis_ping.c: Likewise. + * src/nisplus/nis_print.c: Likewise. + * src/nisplus/nis_print_group_entry.c: Likewise. + * src/nisplus/nis_remove.c: Likewise. + * src/nisplus/nis_removemember.c: Likewise. + * src/nisplus/nis_rmdir.c: Likewise. + * src/nisplus/nis_server.c: Likewise. + * src/nisplus/nis_subr.c: Likewise. + * src/nisplus/nis_table.c: Likewise. + * src/nisplus/nis_util.c: Likewise. + * src/nisplus/nis_verifygroup.c: Likewise. + * src/nisplus/nis_xdr.c: Likewise. + +2015-06-26 Thorsten Kukuk + + * src/nisplus/nis_error.c: New, implement nis_error functions. + * src/Makefile.am: Add nis_error.c + + * src/Makefile.am: Remove yppasswd.[hx] + * src/rpcsvc/yppasswd.h: Removed. + * src/rpcsvc/yppasswd.x: Removed. + + * Initial version, standalone port from glibc version diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..007e939 --- /dev/null +++ b/INSTALL @@ -0,0 +1,370 @@ +Installation Instructions +************************* + +Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, +Inc. + + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. + +Basic Installation +================== + + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + + The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package, generally using the just-built uninstalled binaries. + + 4. Type `make install' to install the programs and any data files and + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. + + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + HP-UX `make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as `configure' are involved. Use GNU `make' +instead. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS + KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf limitation. Until the limitation is lifted, you can use +this workaround: + + CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..63ec0a3 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,15 @@ +# +# Copyright (c) 2015 Thorsten Kukuk, Germany +# +# Author: Thorsten Kukuk +# +AUTOMAKE_OPTIONS = 1.9 gnu dist-bzip2 check-news +ACLOCAL_AMFLAGS=-I m4 +CLEANFILES = *~ + +SUBDIRS = po src + +pkgconfigdir=$(libdir)/pkgconfig +pkgconfig_DATA = libnsl.pc + +EXTRA_DIST = config.rpath diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..44f15c7 --- /dev/null +++ b/NEWS @@ -0,0 +1,28 @@ +libnsl NEWS -- history of user-visible changes. + +Version 1.2.0 +* Replace all glibc specific code to make it more portable + +Version 1.1.0 +* Add rpcgen generated yp.h +* Fix problems with new glibc + +Version 1.0.5 +* Fix some compiler warnings + +Version 1.0.4 +* Make yppasswd.h compatible with glibc version + +Version 1.0.3 +* Export some internal functions marked as private for + libnss_nisplus plugin + +Version 1.0.2 +* Add some missing header files and functions, remove + obsolete prototypes from public headers + +Version 1.0.1 +* Enable more code disabled for old libtirpc versions + +Version 1.0 +* Initial release diff --git a/README b/README new file mode 100644 index 0000000..d714d11 --- /dev/null +++ b/README @@ -0,0 +1,14 @@ + +See the file COPYING for copying restrictions. + +This package contains the libnsl library. This library contains +the public client interface for NIS(YP) and NIS+. + +This code was formerly part of glibc, but is now standalone to +be able to link against TI-RPC for IPv6 support. + +The NIS(YP) functions are still maintained, the NIS+ part is +deprecated and should not be used anymore. + +The git repository can be found at: +https://github.com/thkukuk/libnsl diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..3b32527 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,10 @@ +#!/bin/sh -x + +rm -fv ltmain.sh config.sub config.guess config.h.in +mkdir -p m4 +aclocal -I m4 +autoheader +libtoolize --automake --copy +automake --add-missing --copy --force +autoreconf +chmod 755 configure diff --git a/config.guess b/config.guess new file mode 100755 index 0000000..c6fad2f --- /dev/null +++ b/config.guess @@ -0,0 +1,1568 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2013 Free Software Foundation, Inc. + +timestamp='2013-06-10' + +# This file 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 3 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, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# +# Please send patches with a ChangeLog entry to config-patches@gnu.org. + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2013 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + ;; +esac + +case "${UNAME_MACHINE}" in + i?86) + test -z "$VENDOR" && VENDOR=pc + ;; + *) + test -z "$VENDOR" && VENDOR=unknown + ;; +esac +test -f /etc/SuSE-release -o -f /.buildenv && VENDOR=suse + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-${VENDOR}-bitrig${UNAME_RELEASE} + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-${VENDOR}-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-${VENDOR}-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-${VENDOR}-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-${VENDOR}-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-${VENDOR}-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-${VENDOR}-osf1mk + else + echo ${UNAME_MACHINE}-${VENDOR}-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-${VENDOR}-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-${VENDOR}-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-${VENDOR}-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-${VENDOR}-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-${VENDOR}-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-${VENDOR}-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-${VENDOR}-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-${VENDOR}-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-${VENDOR}-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-${VENDOR}-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-${VENDOR}-linux-${LIBC}"; exit; } + ;; + or1k:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + or32:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-${VENDOR}-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-${VENDOR}-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-${VENDOR}-linux-${LIBC} ;; + PA8*) echo hppa2.0-${VENDOR}-linux-${LIBC} ;; + *) echo hppa-${VENDOR}-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-${VENDOR}-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-${VENDOR}-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-${VENDOR}-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-${VENDOR}-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-${VENDOR}-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-${VENODR}-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-${VENDOR}-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-${VENODR}-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-${VENDOR}-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-${VENDOR}-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-${VENDOR}-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-${VENDOR}-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-${VENDOR}-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-${VENDOR}-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-${VENDOR}-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-${VENDOR}-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-${VENDOR}-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-${VENDOR}-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-${VENDOR}-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-esx + exit ;; +esac + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..85396d4 --- /dev/null +++ b/config.h.in @@ -0,0 +1,122 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#undef ENABLE_NLS + +/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the + CoreFoundation framework. */ +#undef HAVE_CFLOCALECOPYCURRENT + +/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in + the CoreFoundation framework. */ +#undef HAVE_CFPREFERENCESCOPYAPPVALUE + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +#undef HAVE_DCGETTEXT + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define if the GNU gettext() function is already present or preinstalled. */ +#undef HAVE_GETTEXT + +/* Define if you have the iconv() function and it works. */ +#undef HAVE_ICONV + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if TIRPC is available */ +#undef HAVE_TIRPC + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE diff --git a/config.rpath b/config.rpath new file mode 100755 index 0000000..b625621 --- /dev/null +++ b/config.rpath @@ -0,0 +1,684 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2014 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's _LT_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + mingw* | cygwin* | pw32* | os2* | cegcc*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu) + case $cc_basename in + ecc*) + wl='-Wl,' + ;; + icc* | ifort*) + wl='-Wl,' + ;; + lf95*) + wl='-Wl,' + ;; + nagfor*) + wl='-Wl,-Wl,,' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + xl* | bgxl* | bgf* | mpixl*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ F* | *Sun*Fortran*) + wl= + ;; + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + newsos6) + ;; + *nto* | *qnx*) + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + wl='-Qoption ld ' + ;; + *) + wl='-Wl,' + ;; + esac + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's _LT_LINKER_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + case "$host_cpu" in + powerpc) + ;; + m68k) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32* | cegcc*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + haiku*) + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + case "$host_cpu" in + powerpc) + ;; + m68k) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + bsdi[45]*) + ;; + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then + : + else + ld_shlibs=no + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd2.[01]*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + *nto* | *qnx*) + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix[4-9]*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + case "$host_cpu" in + powerpc*) + library_names_spec='$libname$shrext' ;; + m68k) + library_names_spec='$libname.a' ;; + esac + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32* | cegcc*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd[23].*) + library_names_spec='$libname$shrext$versuffix' + ;; + freebsd* | dragonfly*) + library_names_spec='$libname$shrext' + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + haiku*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + *nto* | *qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + tpf*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches with a ChangeLog entry to config-patches@gnu.org. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2013 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | be32 | be64 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | epiphany \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 \ + | or1k | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pyramid \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | we32k \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pyramid-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i386-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or1k-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..3eacc09 --- /dev/null +++ b/configure.ac @@ -0,0 +1,38 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(libnsl, 1.2.0) +AM_INIT_AUTOMAKE +AC_CONFIG_SRCDIR([src/do_ypcall.c]) +AM_CONFIG_HEADER(config.h) +AC_CONFIG_MACRO_DIR([m4]) +AC_PREFIX_DEFAULT(/usr) + +AC_SUBST(PACKAGE) +AC_SUBST(VERSION) + +dnl Checks for programs. +AC_PROG_CC +AC_GNU_SOURCE +AM_PROG_CC_C_O +dnl If we're using gcc, we want warning flags +dnl test -n "$GCC" && WARNFLAGS="-Wall" +test -n "$GCC" && WARNFLAGS="-W -Wall -Wbad-function-cast -Wcast-align -Winline -Wnested-externs -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef" +AC_SUBST(WARNFLAGS) +AC_PROG_CPP +AC_ISC_POSIX +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AC_PROG_LIBTOOL +LT_INIT + +dnl Checks for libraries. +PKG_CHECK_MODULES([TIRPC], [libtirpc], [], [TIRPC_LIBS=""]) + +if test -n "$TIRPC_LIBS"; then + AC_DEFINE(HAVE_TIRPC, 1, [Define to 1 if TIRPC is available]) +fi + +dnl internationalization macros +AM_GNU_GETTEXT_VERSION([0.19.2]) +AM_GNU_GETTEXT([external]) + +AC_OUTPUT([Makefile src/Makefile libnsl.pc po/Makefile.in]) diff --git a/libnsl.pc.in b/libnsl.pc.in new file mode 100644 index 0000000..27558d0 --- /dev/null +++ b/libnsl.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libnsl +Description: Library containing NIS functions using TI-RPC (IPv6 enabled) +Requires: libtirpc >= 1.0.1 +Version: @PACKAGE_VERSION@ +Libs: -L@libdir@ -lnsl +Cflags: -I@includedir@ + diff --git a/po/Makefile.in.in b/po/Makefile.in.in new file mode 100644 index 0000000..65184f6 --- /dev/null +++ b/po/Makefile.in.in @@ -0,0 +1,475 @@ +# Makefile for PO directory in any package using GNU gettext. +# Copyright (C) 1995-1997, 2000-2007, 2009-2010 by Ulrich Drepper +# +# This file can be copied and used freely without restrictions. It can +# be used in projects which are not available under the GNU General Public +# License but which still want to provide support for the GNU gettext +# functionality. +# Please note that the actual code of GNU gettext is covered by the GNU +# General Public License and is *not* in the public domain. +# +# Origin: gettext-0.19 +GETTEXT_MACRO_VERSION = 0.19 + +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ + +SED = @SED@ +SHELL = /bin/sh +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ +datadir = @datadir@ +localedir = @localedir@ +gettextsrcdir = $(datadir)/gettext/po + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +# We use $(mkdir_p). +# In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as +# "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions, +# @install_sh@ does not start with $(SHELL), so we add it. +# In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined +# either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake +# versions, $(mkinstalldirs) and $(install_sh) are unused. +mkinstalldirs = $(SHELL) @install_sh@ -d +install_sh = $(SHELL) @install_sh@ +MKDIR_P = @MKDIR_P@ +mkdir_p = @mkdir_p@ + +GMSGFMT_ = @GMSGFMT@ +GMSGFMT_no = @GMSGFMT@ +GMSGFMT_yes = @GMSGFMT_015@ +GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT)) +MSGFMT_ = @MSGFMT@ +MSGFMT_no = @MSGFMT@ +MSGFMT_yes = @MSGFMT_015@ +MSGFMT = $(MSGFMT_$(USE_MSGCTXT)) +XGETTEXT_ = @XGETTEXT@ +XGETTEXT_no = @XGETTEXT@ +XGETTEXT_yes = @XGETTEXT_015@ +XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT)) +MSGMERGE = msgmerge +MSGMERGE_UPDATE = @MSGMERGE@ --update +MSGINIT = msginit +MSGCONV = msgconv +MSGFILTER = msgfilter + +POFILES = @POFILES@ +GMOFILES = @GMOFILES@ +UPDATEPOFILES = @UPDATEPOFILES@ +DUMMYPOFILES = @DUMMYPOFILES@ +DISTFILES.common = Makefile.in.in remove-potcdate.sin \ +$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3) +DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \ +$(POFILES) $(GMOFILES) \ +$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3) + +POTFILES = \ + +CATALOGS = @CATALOGS@ + +POFILESDEPS_ = $(srcdir)/$(DOMAIN).pot +POFILESDEPS_yes = $(POFILESDEPS_) +POFILESDEPS_no = +POFILESDEPS = $(POFILESDEPS_$(PO_DEPENDS_ON_POT)) + +DISTFILESDEPS_ = update-po +DISTFILESDEPS_yes = $(DISTFILESDEPS_) +DISTFILESDEPS_no = +DISTFILESDEPS = $(DISTFILESDEPS_$(DIST_DEPENDS_ON_UPDATE_PO)) + +# Makevars gets inserted here. (Don't remove this line!) + +.SUFFIXES: +.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update + +.po.mo: + @echo "$(MSGFMT) -c -o $@ $<"; \ + $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@ + +.po.gmo: + @lang=`echo $* | sed -e 's,.*/,,'`; \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.po"; \ + cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo + +.sin.sed: + sed -e '/^#/d' $< > t-$@ + mv t-$@ $@ + + +all: all-@USE_NLS@ + +all-yes: stamp-po +all-no: + +# Ensure that the gettext macros and this Makefile.in.in are in sync. +CHECK_MACRO_VERSION = \ + test "$(GETTEXT_MACRO_VERSION)" = "@GETTEXT_MACRO_VERSION@" \ + || { echo "*** error: gettext infrastructure mismatch: using a Makefile.in.in from gettext version $(GETTEXT_MACRO_VERSION) but the autoconf macros are from gettext version @GETTEXT_MACRO_VERSION@" 1>&2; \ + exit 1; \ + } + +# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no +# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because +# we don't want to bother translators with empty POT files). We assume that +# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty. +# In this case, stamp-po is a nop (i.e. a phony target). + +# stamp-po is a timestamp denoting the last time at which the CATALOGS have +# been loosely updated. Its purpose is that when a developer or translator +# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, +# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent +# invocations of "make" will do nothing. This timestamp would not be necessary +# if updating the $(CATALOGS) would always touch them; however, the rule for +# $(POFILES) has been designed to not touch files that don't need to be +# changed. +stamp-po: $(srcdir)/$(DOMAIN).pot + @$(CHECK_MACRO_VERSION) + test ! -f $(srcdir)/$(DOMAIN).pot || \ + test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES) + @test ! -f $(srcdir)/$(DOMAIN).pot || { \ + echo "touch stamp-po" && \ + echo timestamp > stamp-poT && \ + mv stamp-poT stamp-po; \ + } + +# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', +# otherwise packages like GCC can not be built if only parts of the source +# have been downloaded. + +# This target rebuilds $(DOMAIN).pot; it is an expensive operation. +# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. +# The determination of whether the package xyz is a GNU one is based on the +# heuristic whether some file in the top level directory mentions "GNU xyz". +# If GNU 'find' is available, we avoid grepping through monster files. +$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed + package_gnu="$(PACKAGE_GNU)"; \ + test -n "$$package_gnu" || { \ + if { if (LC_ALL=C find --version) 2>/dev/null | grep GNU >/dev/null; then \ + LC_ALL=C find -L $(top_srcdir) -maxdepth 1 -type f \ + -size -10000000c -exec grep 'GNU @PACKAGE@' \ + /dev/null '{}' ';' 2>/dev/null; \ + else \ + LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null; \ + fi; \ + } | grep -v 'libtool:' >/dev/null; then \ + package_gnu=yes; \ + else \ + package_gnu=no; \ + fi; \ + }; \ + if test "$$package_gnu" = "yes"; then \ + package_prefix='GNU '; \ + else \ + package_prefix=''; \ + fi; \ + if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \ + msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ + else \ + msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ + fi; \ + case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \ + $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ + --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ + --files-from=$(srcdir)/POTFILES.in \ + --copyright-holder='$(COPYRIGHT_HOLDER)' \ + --msgid-bugs-address="$$msgid_bugs_address" \ + ;; \ + *) \ + $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ + --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ + --files-from=$(srcdir)/POTFILES.in \ + --copyright-holder='$(COPYRIGHT_HOLDER)' \ + --package-name="$${package_prefix}@PACKAGE@" \ + --package-version='@VERSION@' \ + --msgid-bugs-address="$$msgid_bugs_address" \ + ;; \ + esac + test ! -f $(DOMAIN).po || { \ + if test -f $(srcdir)/$(DOMAIN).pot; then \ + sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ + sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ + if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ + rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ + else \ + rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ + mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ + fi; \ + else \ + mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ + fi; \ + } + +# This rule has no dependencies: we don't need to update $(DOMAIN).pot at +# every "make" invocation, only create it when it is missing. +# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. +$(srcdir)/$(DOMAIN).pot: + $(MAKE) $(DOMAIN).pot-update + +# This target rebuilds a PO file if $(DOMAIN).pot has changed. +# Note that a PO file is not touched if it doesn't need to be changed. +$(POFILES): $(POFILESDEPS) + @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ + if test -f "$(srcdir)/$${lang}.po"; then \ + test -f $(srcdir)/$(DOMAIN).pot || $(MAKE) $(srcdir)/$(DOMAIN).pot; \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \ + cd $(srcdir) \ + && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ + $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \ + *) \ + $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot;; \ + esac; \ + }; \ + else \ + $(MAKE) $${lang}.po-create; \ + fi + + +install: install-exec install-data +install-exec: +install-data: install-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ + for file in $(DISTFILES.common) Makevars.template; do \ + $(INSTALL_DATA) $(srcdir)/$$file \ + $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + for file in Makevars; do \ + rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + else \ + : ; \ + fi +install-data-no: all +install-data-yes: all + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + dir=$(localedir)/$$lang/LC_MESSAGES; \ + $(mkdir_p) $(DESTDIR)$$dir; \ + if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ + $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \ + echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \ + for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ + if test -n "$$lc"; then \ + if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ + link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ + mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ + for file in *; do \ + if test -f $$file; then \ + ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ + fi; \ + done); \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + else \ + if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ + :; \ + else \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + fi; \ + fi; \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ + ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ + cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \ + fi; \ + done; \ + done + +install-strip: install + +installdirs: installdirs-exec installdirs-data +installdirs-exec: +installdirs-data: installdirs-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ + else \ + : ; \ + fi +installdirs-data-no: +installdirs-data-yes: + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + dir=$(localedir)/$$lang/LC_MESSAGES; \ + $(mkdir_p) $(DESTDIR)$$dir; \ + for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ + if test -n "$$lc"; then \ + if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ + link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ + mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ + for file in *; do \ + if test -f $$file; then \ + ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ + fi; \ + done); \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + else \ + if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ + :; \ + else \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + fi; \ + fi; \ + fi; \ + done; \ + done + +# Define this as empty until I found a useful application. +installcheck: + +uninstall: uninstall-exec uninstall-data +uninstall-exec: +uninstall-data: uninstall-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + for file in $(DISTFILES.common) Makevars.template; do \ + rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + else \ + : ; \ + fi +uninstall-data-no: +uninstall-data-yes: + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + done; \ + done + +check: all + +info dvi ps pdf html tags TAGS ctags CTAGS ID: + +mostlyclean: + rm -f remove-potcdate.sed + rm -f stamp-poT + rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po + rm -fr *.o + +clean: mostlyclean + +distclean: clean + rm -f Makefile Makefile.in POTFILES *.mo + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f stamp-po $(GMOFILES) + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: + test -z "$(DISTFILESDEPS)" || $(MAKE) $(DISTFILESDEPS) + @$(MAKE) dist2 +# This is a separate target because 'update-po' must be executed before. +dist2: stamp-po $(DISTFILES) + dists="$(DISTFILES)"; \ + if test "$(PACKAGE)" = "gettext-tools"; then \ + dists="$$dists Makevars.template"; \ + fi; \ + if test -f $(srcdir)/$(DOMAIN).pot; then \ + dists="$$dists $(DOMAIN).pot stamp-po"; \ + fi; \ + if test -f $(srcdir)/ChangeLog; then \ + dists="$$dists ChangeLog"; \ + fi; \ + for i in 0 1 2 3 4 5 6 7 8 9; do \ + if test -f $(srcdir)/ChangeLog.$$i; then \ + dists="$$dists ChangeLog.$$i"; \ + fi; \ + done; \ + if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \ + for file in $$dists; do \ + if test -f $$file; then \ + cp -p $$file $(distdir) || exit 1; \ + else \ + cp -p $(srcdir)/$$file $(distdir) || exit 1; \ + fi; \ + done + +update-po: Makefile + $(MAKE) $(DOMAIN).pot-update + test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) + $(MAKE) update-gmo + +# General rule for creating PO files. + +.nop.po-create: + @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ + echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ + exit 1 + +# General rule for updating PO files. + +.nop.po-update: + @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ + if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \ + tmpdir=`pwd`; \ + echo "$$lang:"; \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ + cd $(srcdir); \ + if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ + $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ + *) \ + $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ + esac; \ + }; then \ + if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "msgmerge for $$lang.po failed!" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi + +$(DUMMYPOFILES): + +update-gmo: Makefile $(GMOFILES) + @: + +# Recreate Makefile by invoking config.status. Explicitly invoke the shell, +# because execution permission bits may not work on the current file system. +# Use @SHELL@, which is the shell determined by autoconf for the use by its +# scripts, not $(SHELL) which is hardwired to /bin/sh and may be deficient. +Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@ + cd $(top_builddir) \ + && @SHELL@ ./config.status $(subdir)/$@.in po-directories + +force: + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 0000000..727839f --- /dev/null +++ b/po/Makevars @@ -0,0 +1,72 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# 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 = Thorsten Kukuk + +# This tells whether or not to prepend "GNU " prefix to the package +# name that gets inserted into the header of the $(DOMAIN).pot file. +# Possible values are "yes", "no", or empty. If it is empty, try to +# detect it automatically by scanning the files in $(top_srcdir) for +# "GNU packagename" string. +PACKAGE_GNU = + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# 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 = + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = + +# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' +# 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 + +# These options get passed to msgmerge. +# Useful options are in particular: +# --previous to keep previous msgids of translated messages, +# --quiet to reduce the verbosity. +MSGMERGE_OPTIONS = + +# This tells whether or not to regenerate a PO file when $(DOMAIN).pot +# has changed. Possible values are "yes" and "no". Set this to no if +# the POT file is checked in the repository and the version control +# program ignores timestamps. +PO_DEPENDS_ON_POT = yes + +# This tells whether or not to forcibly update $(DOMAIN).pot and +# regenerate PO files on "make dist". Possible values are "yes" and +# "no". Set this to no if the POT file and PO files are maintained +# externally. +DIST_DEPENDS_ON_UPDATE_PO = yes diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..94f333a --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,13 @@ +# List of source files which contain translatable strings. +src/do_ypcall.c +src/ypbinderr_string.c +src/yperr_string.c +src/yp_first.c +src/yp_get_default_domain.c +src/yp_maplist.c +src/yp_master.c +src/yp_match.c +src/yp_next.c +src/yp_order.c +src/ypprot_err.c +src/yp_xdr.c diff --git a/po/Rules-quot b/po/Rules-quot new file mode 100644 index 0000000..7b92c7e --- /dev/null +++ b/po/Rules-quot @@ -0,0 +1,58 @@ +# This file, Rules-quot, can be copied and used freely without restrictions. +# Special Makefile rules for English message catalogs with quotation marks. + +DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot + +.SUFFIXES: .insert-header .po-update-en + +en@quot.po-create: + $(MAKE) en@quot.po-update +en@boldquot.po-create: + $(MAKE) en@boldquot.po-update + +en@quot.po-update: en@quot.po-update-en +en@boldquot.po-update: en@boldquot.po-update-en + +.insert-header.po-update-en: + @lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \ + if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ + tmpdir=`pwd`; \ + echo "$$lang:"; \ + ll=`echo $$lang | sed -e 's/@.*//'`; \ + LC_ALL=C; export LC_ALL; \ + cd $(srcdir); \ + if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$lang -o - 2>/dev/null \ + | $(SED) -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | \ + { case `$(MSGFILTER) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-8] | 0.1[0-8].*) \ + $(MSGFILTER) $(SED) -f `echo $$lang | sed -e 's/.*@//'`.sed \ + ;; \ + *) \ + $(MSGFILTER) `echo $$lang | sed -e 's/.*@//'` \ + ;; \ + esac } 2>/dev/null > $$tmpdir/$$lang.new.po \ + ; then \ + if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "creation of $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "creation of $$lang.po failed!" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi + +en@quot.insert-header: insert-header.sin + sed -e '/^#/d' -e 's/HEADER/en@quot.header/g' $(srcdir)/insert-header.sin > en@quot.insert-header + +en@boldquot.insert-header: insert-header.sin + sed -e '/^#/d' -e 's/HEADER/en@boldquot.header/g' $(srcdir)/insert-header.sin > en@boldquot.insert-header + +mostlyclean: mostlyclean-quot +mostlyclean-quot: + rm -f *.insert-header diff --git a/po/boldquot.sed b/po/boldquot.sed new file mode 100644 index 0000000..4b937aa --- /dev/null +++ b/po/boldquot.sed @@ -0,0 +1,10 @@ +s/"\([^"]*\)"/“\1”/g +s/`\([^`']*\)'/‘\1’/g +s/ '\([^`']*\)' / ‘\1’ /g +s/ '\([^`']*\)'$/ ‘\1’/g +s/^'\([^`']*\)' /‘\1’ /g +s/“”/""/g +s/“/“/g +s/”/”/g +s/‘/‘/g +s/’/’/g diff --git a/po/en@boldquot.header b/po/en@boldquot.header new file mode 100644 index 0000000..fedb6a0 --- /dev/null +++ b/po/en@boldquot.header @@ -0,0 +1,25 @@ +# All this catalog "translates" are quotation characters. +# The msgids must be ASCII and therefore cannot contain real quotation +# characters, only substitutes like grave accent (0x60), apostrophe (0x27) +# and double quote (0x22). These substitutes look strange; see +# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html +# +# This catalog translates grave accent (0x60) and apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019). +# It also translates pairs of apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019) +# and pairs of quotation mark (0x22) to +# left double quotation mark (U+201C) and right double quotation mark (U+201D). +# +# When output to an UTF-8 terminal, the quotation characters appear perfectly. +# When output to an ISO-8859-1 terminal, the single quotation marks are +# transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to +# grave/acute accent (by libiconv), and the double quotation marks are +# transliterated to 0x22. +# When output to an ASCII terminal, the single quotation marks are +# transliterated to apostrophes, and the double quotation marks are +# transliterated to 0x22. +# +# This catalog furthermore displays the text between the quotation marks in +# bold face, assuming the VT100/XTerm escape sequences. +# diff --git a/po/en@quot.header b/po/en@quot.header new file mode 100644 index 0000000..a9647fc --- /dev/null +++ b/po/en@quot.header @@ -0,0 +1,22 @@ +# All this catalog "translates" are quotation characters. +# The msgids must be ASCII and therefore cannot contain real quotation +# characters, only substitutes like grave accent (0x60), apostrophe (0x27) +# and double quote (0x22). These substitutes look strange; see +# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html +# +# This catalog translates grave accent (0x60) and apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019). +# It also translates pairs of apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019) +# and pairs of quotation mark (0x22) to +# left double quotation mark (U+201C) and right double quotation mark (U+201D). +# +# When output to an UTF-8 terminal, the quotation characters appear perfectly. +# When output to an ISO-8859-1 terminal, the single quotation marks are +# transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to +# grave/acute accent (by libiconv), and the double quotation marks are +# transliterated to 0x22. +# When output to an ASCII terminal, the single quotation marks are +# transliterated to apostrophes, and the double quotation marks are +# transliterated to 0x22. +# diff --git a/po/insert-header.sin b/po/insert-header.sin new file mode 100644 index 0000000..b26de01 --- /dev/null +++ b/po/insert-header.sin @@ -0,0 +1,23 @@ +# Sed script that inserts the file called HEADER before the header entry. +# +# At each occurrence of a line starting with "msgid ", we execute the following +# commands. At the first occurrence, insert the file. At the following +# occurrences, do nothing. The distinction between the first and the following +# occurrences is achieved by looking at the hold space. +/^msgid /{ +x +# Test if the hold space is empty. +s/m/m/ +ta +# Yes it was empty. First occurrence. Read the file. +r HEADER +# Output the file's contents by reading the next line. But don't lose the +# current line while doing this. +g +N +bb +:a +# The hold space was nonempty. Following occurrences. Do nothing. +x +:b +} diff --git a/po/libnsl.pot b/po/libnsl.pot new file mode 100644 index 0000000..9c60f6b --- /dev/null +++ b/po/libnsl.pot @@ -0,0 +1,110 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Thorsten Kukuk +# This file is distributed under the same license as the libnsl package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: libnsl 1.2.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-11 08:11+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/ypbinderr_string.c:42 src/yperr_string.c:40 +msgid "Success" +msgstr "" + +#: src/ypbinderr_string.c:45 +msgid "Internal ypbind error" +msgstr "" + +#: src/ypbinderr_string.c:48 +msgid "Domain not bound" +msgstr "" + +#: src/ypbinderr_string.c:51 +msgid "System resource allocation failure" +msgstr "" + +#: src/ypbinderr_string.c:54 +msgid "Domain doesn't exist" +msgstr "" + +#: src/ypbinderr_string.c:57 +msgid "Unknown ypbind error" +msgstr "" + +#: src/yperr_string.c:43 +msgid "Request arguments bad" +msgstr "" + +#: src/yperr_string.c:46 +msgid "RPC failure on NIS operation" +msgstr "" + +#: src/yperr_string.c:49 +msgid "Can't bind to server which serves this domain" +msgstr "" + +#: src/yperr_string.c:52 +msgid "No such map in server's domain" +msgstr "" + +#: src/yperr_string.c:55 +msgid "No such key in map" +msgstr "" + +#: src/yperr_string.c:58 +msgid "Internal NIS error" +msgstr "" + +#: src/yperr_string.c:61 +msgid "Local resource allocation failure" +msgstr "" + +#: src/yperr_string.c:64 +msgid "No more records in map database" +msgstr "" + +#: src/yperr_string.c:67 +msgid "Can't communicate with portmapper" +msgstr "" + +#: src/yperr_string.c:70 +msgid "Can't communicate with ypbind" +msgstr "" + +#: src/yperr_string.c:73 +msgid "Can't communicate with ypserv" +msgstr "" + +#: src/yperr_string.c:76 +msgid "Local domain name not set" +msgstr "" + +#: src/yperr_string.c:79 +msgid "NIS map database is bad" +msgstr "" + +#: src/yperr_string.c:82 +msgid "NIS client/server version mismatch - can't supply service" +msgstr "" + +#: src/yperr_string.c:85 +msgid "Permission denied" +msgstr "" + +#: src/yperr_string.c:88 +msgid "Database is busy" +msgstr "" + +#: src/yperr_string.c:91 +msgid "Unknown NIS error code" +msgstr "" diff --git a/po/quot.sed b/po/quot.sed new file mode 100644 index 0000000..0122c46 --- /dev/null +++ b/po/quot.sed @@ -0,0 +1,6 @@ +s/"\([^"]*\)"/“\1”/g +s/`\([^`']*\)'/‘\1’/g +s/ '\([^`']*\)' / ‘\1’ /g +s/ '\([^`']*\)'$/ ‘\1’/g +s/^'\([^`']*\)' /‘\1’ /g +s/“”/""/g diff --git a/po/remove-potcdate.sin b/po/remove-potcdate.sin new file mode 100644 index 0000000..2436c49 --- /dev/null +++ b/po/remove-potcdate.sin @@ -0,0 +1,19 @@ +# Sed script that remove the POT-Creation-Date line in the header entry +# from a POT file. +# +# The distinction between the first and the following occurrences of the +# pattern is achieved by looking at the hold space. +/^"POT-Creation-Date: .*"$/{ +x +# Test if the hold space is empty. +s/P/P/ +ta +# Yes it was empty. First occurrence. Remove the line. +g +d +bb +:a +# The hold space was nonempty. Following occurrences. Do nothing. +x +:b +} diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..792d846 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,53 @@ +# +# Copyright (c) 2015, 2017 Thorsten Kukuk, Germany +# +# Author: Thorsten Kukuk +# +# Process this file with automake to produce Makefile.in. +# + +CLEANFILES = *~ + +EXTRA_DIST = libnsl.map + +localedir = $(datadir)/locale +rpcsvcdir = $(includedir)/rpcsvc + +AM_CFLAGS = @WARNFLAGS@ -D_REENTRANT=1 +AM_CPPFLAGS = -I$(srcdir) @TIRPC_CFLAGS@ -DLOCALEDIR=\"$(localedir)\" + +rpcsvc_HEADERS = rpcsvc/ypclnt.h rpcsvc/ypupd.h rpcsvc/yp_prot.h \ + rpcsvc/yp.x rpcsvc/yp.h rpcsvc/nis_callback.h rpcsvc/nis.h \ + rpcsvc/nis_object.x rpcsvc/nis.x rpcsvc/nis_callback.x \ + rpcsvc/nislib.h rpcsvc/nis_tags.h rpcsvc/yppasswd.x \ + rpcsvc/yppasswd.h + +noinst_HEADERS = internal.h libc-lock.h nisplus/nis_intern.h nisplus/nis_xdr.h + +lib_LTLIBRARIES = libnsl.la + +libnsl_la_LDFLAGS = -version-info 2:0:0 \ + -Wl,--no-undefined \ + -Wl,--version-script=$(srcdir)/libnsl.map +libnsl_la_LIBADD = @TIRPC_LIBS@ @LTLIBINTL@ + +libnsl_la_SOURCES = yp_xdr.c do_ypcall.c ypprot_err.c yp_master.c \ + yp_maplist.c yp_order.c yp_first.c yp_next.c yp_match.c \ + yperr_string.c ypbinderr_string.c yp_get_default_domain.c \ + taddr2host.c taddr2ipstr.c taddr2port.c \ + nisplus/nis_add.c nisplus/nis_addmember.c nisplus/nis_callback.c \ + nisplus/nis_call.c nisplus/nis_checkpoint.c nisplus/nis_clone_dir.c \ + nisplus/nis_clone_obj.c nisplus/nis_clone_res.c \ + nisplus/nis_creategroup.c nisplus/nis_defaults.c \ + nisplus/nis_destroygroup.c nisplus/nis_domain_of.c \ + nisplus/nis_domain_of_r.c nisplus/nis_error.c \ + nisplus/nis_file.c nisplus/nis_findserv.c nisplus/nis_free.c \ + nisplus/nis_getservlist.c nisplus/nis_ismember.c \ + nisplus/nis_local_names.c nisplus/nis_lookup.c nisplus/nis_mkdir.c \ + nisplus/nis_modify.c nisplus/nis_ping.c nisplus/nis_print.c \ + nisplus/nis_print_group_entry.c nisplus/nis_remove.c \ + nisplus/nis_removemember.c nisplus/nis_rmdir.c nisplus/nis_server.c \ + nisplus/nis_subr.c nisplus/nis_table.c nisplus/nis_util.c \ + nisplus/nis_verifygroup.c nisplus/nis_xdr.c + +# nisplus/nis_hash.c diff --git a/src/do_ypcall.c b/src/do_ypcall.c new file mode 100644 index 0000000..480ccc6 --- /dev/null +++ b/src/do_ypcall.c @@ -0,0 +1,635 @@ +/* Copyright (C) 2014, 2017, 2018 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "internal.h" + +/* This should only be defined on systems with a BSD compatible ypbind */ +#ifndef BINDINGDIR +# define BINDINGDIR "/var/yp/binding" +#endif + +struct dom_binding + { + struct dom_binding *dom_pnext; + char dom_domain[YPMAXDOMAIN + 1]; + char *server; + CLIENT *dom_client; + }; +typedef struct dom_binding dom_binding; + +static const struct timeval RPCTIMEOUT = {25, 0}; +static int const MAXTRIES = 2; +static pthread_mutex_t ypbindlist_lock = PTHREAD_MUTEX_INITIALIZER; +static dom_binding *ypbindlist = NULL; +static __thread int from_yp_all = 0; + +#if defined(HAVE_TIRPC) +static const char * +get_server_str (struct ypbind3_binding *ypb3, char *buf, size_t buflen) +{ + if (ypb3->ypbind_servername != NULL) + return ypb3->ypbind_servername; + + return taddr2ipstr (ypb3->ypbind_nconf, ypb3->ypbind_svcaddr, + buf, buflen); +} + +static void +yp_bind_client_create_v3 (const char *domain, dom_binding *ysd, + struct ypbind3_binding *ypb3) +{ + char buf[INET6_ADDRSTRLEN]; + + if (ysd->server) + free (ysd->server); + ysd->server = strdup (get_server_str (ypb3, buf, sizeof(buf))); + strncpy (ysd->dom_domain, domain, YPMAXDOMAIN); + ysd->dom_domain[YPMAXDOMAIN] = '\0'; + + ysd->dom_client = clnt_create (ysd->server, YPPROG, YPVERS, "udp"); + if (ysd->dom_client == NULL) + clnt_pcreateerror ("yp_bind_client_create_v3"); +} +#endif + +static void +yp_bind_client_create_v2 (const char *domain, dom_binding *ysd, + struct ypbind2_resp *ypbr) +{ + ysd->server = strdup (inet_ntoa (ypbr->ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr)); + strncpy (ysd->dom_domain, domain, YPMAXDOMAIN); + ysd->dom_domain[YPMAXDOMAIN] = '\0'; + + ysd->dom_client = clnt_create (ysd->server, YPPROG, YPVERS, "udp"); + if (ysd->dom_client == NULL) + clnt_pcreateerror ("yp_bind_client_create_v2"); +} + +static void +yp_bind_file (const char *domain, dom_binding *ysd) +{ + char path[sizeof (BINDINGDIR) + strlen (domain) + 3 * sizeof (unsigned) + 3]; + +#if defined(HAVE_TIRPC) + snprintf (path, sizeof (path), "%s/%s.%u", BINDINGDIR, domain, YPBINDVERS); + + FILE *in = fopen (path, "rce"); + if (in != NULL) + { + struct ypbind3_binding ypb3; + bool_t status; + + XDR xdrs; + xdrstdio_create (&xdrs, in, XDR_DECODE); + memset (&ypb3, 0, sizeof (ypb3)); + status = xdr_ypbind3_binding (&xdrs, &ypb3); + xdr_destroy (&xdrs); + + if (!status) + { + xdr_free ((xdrproc_t)xdr_ypbind3_binding, (char *)&ypb3); + fclose (in); + goto version2; + } + yp_bind_client_create_v3 (domain, ysd, &ypb3); + xdr_free ((xdrproc_t)xdr_ypbind3_binding, (char *)&ypb3); + fclose (in); + } + else +#endif /* HAVE_TIRPC */ + { + int fd; + version2: + + snprintf (path, sizeof (path), "%s/%s.%u", BINDINGDIR, domain, 2); + fd = open (path, O_RDONLY); + if (fd >= 0) + { + /* We have a binding file and could save a RPC call. The file + contains a port number and the YPBIND_RESP record. The port + number (16 bits) can be ignored. */ + struct ypbind2_resp ypbr; + + if (pread (fd, &ypbr, sizeof (ypbr), 2) == sizeof (ypbr)) + yp_bind_client_create_v2 (domain, ysd, &ypbr); + + close (fd); + } + } +} + +static int +yp_bind_ypbindprog (const char *domain, dom_binding *ysd) +{ + CLIENT *client; + +#if defined (HAVE_TIRPC) + client = clnt_create ("localhost", YPBINDPROG, YPBINDVERS, "tcp"); + if (client != NULL) + { + enum clnt_stat ret; + struct ypbind3_resp ypbr; + +#if 0 /* XXX */ + /* Check the port number -- should be < IPPORT_RESERVED. + If not, it's possible someone has registered a bogus + ypbind with the portmapper and is trying to trick us. */ + if (ntohs (clnt_saddr.sin_port) >= IPPORT_RESERVED) + { + clnt_destroy (client); + return YPERR_YPBIND; + } +#endif + + memset (&ypbr, 0, sizeof (ypbr)); + if ((ret = clnt_call (client, YPBINDPROC_DOMAIN, + (xdrproc_t) xdr_domainname, (caddr_t) &domain, + (xdrproc_t) xdr_ypbind3_resp, + (caddr_t) &ypbr, RPCTIMEOUT)) != RPC_SUCCESS) + { + clnt_destroy (client); + if (ret == RPC_PROGVERSMISMATCH) + goto try_v2; + return YPERR_YPBIND; + } + + clnt_destroy (client); + + if (ypbr.ypbind_status != YPBIND_SUCC_VAL) + return YPERR_DOMAIN; + + if (ysd->server) + free (ysd->server); + ysd->server = NULL; + + yp_bind_client_create_v3 (domain, ysd, ypbr.ypbind_respbody.ypbind_bindinfo); + if (ysd->dom_client == NULL) + return YPERR_YPSERV; + } + else +#endif + { + struct ypbind2_resp ypbr; + + try_v2: + /* Fallback to protocol v2 in error case */ + client = clnt_create ("localhost", YPBINDPROG, YPBINDVERS_2, "tcp"); + + if (client == NULL) + return YPERR_YPBIND; + +#if 0 /* XXX */ + /* Check the port number -- should be < IPPORT_RESERVED. + If not, it's possible someone has registered a bogus + ypbind with the portmapper and is trying to trick us. */ + if (ntohs (clnt_saddr.sin_port) >= IPPORT_RESERVED) + { + clnt_destroy (client); + return YPERR_YPBIND; + } +#endif + + memset (&ypbr, 0, sizeof (ypbr)); + if (clnt_call (client, YPBINDPROC_DOMAIN, + (xdrproc_t) xdr_domainname, (caddr_t) &domain, + (xdrproc_t) xdr_ypbind2_resp, + (caddr_t) &ypbr, RPCTIMEOUT) != RPC_SUCCESS) + { + clnt_destroy (client); + return YPERR_YPBIND; + } + + clnt_destroy (client); + + if (ypbr.ypbind_status != YPBIND_SUCC_VAL) + return YPERR_DOMAIN; + + if (ysd->server) + free (ysd->server); + ysd->server = NULL; + + yp_bind_client_create_v2 (domain, ysd, &ypbr); + if (ysd->dom_client == NULL) + return YPERR_YPSERV; + } + + return YPERR_SUCCESS; +} + +static int +__yp_bind (const char *domain, dom_binding **ypdb) +{ + dom_binding *ysd = NULL; + int is_new = 0; + + if (domain == NULL || domain[0] == '\0') + return YPERR_BADARGS; + + ysd = *ypdb; + while (ysd != NULL) + { + if (strcmp (domain, ysd->dom_domain) == 0) + break; + ysd = ysd->dom_pnext; + } + + if (ysd == NULL) + { + is_new = 1; + ysd = (dom_binding *) calloc (1, sizeof *ysd); + if (ysd == NULL) + return YPERR_RESRC; + } + + /* Try binding dir at first if we have no binding */ + if (ysd->dom_client == NULL) + yp_bind_file (domain, ysd); + + if (ysd->dom_client == NULL) + { + int retval = yp_bind_ypbindprog (domain, ysd); + if (retval != YPERR_SUCCESS) + { + if (is_new) + free (ysd); + return retval; + } + } + + if (ysd->dom_client == NULL) + { + if (is_new) + free (ysd); + return YPERR_YPSERV; + } + + if (is_new) + { + ysd->dom_pnext = *ypdb; + *ypdb = ysd; + } + + return YPERR_SUCCESS; +} + +static void +__yp_unbind (dom_binding *ydb) +{ + if (ydb->dom_client) + clnt_destroy (ydb->dom_client); + if (ydb->server) + free (ydb->server); + free (ydb); +} + +int +yp_bind (const char *indomain) +{ + int status; + + pthread_mutex_lock (&ypbindlist_lock); + status = __yp_bind (indomain, &ypbindlist); + pthread_mutex_unlock (&ypbindlist_lock); + + return status; +} + +static void +yp_unbind_locked (const char *indomain) +{ + dom_binding *ydbptr, *ydbptr2; + + ydbptr2 = NULL; + ydbptr = ypbindlist; + + while (ydbptr != NULL) + { + if (strcmp (ydbptr->dom_domain, indomain) == 0) + { + dom_binding *work; + + work = ydbptr; + if (ydbptr2 == NULL) + ypbindlist = ypbindlist->dom_pnext; + else + ydbptr2 = ydbptr->dom_pnext; + __yp_unbind (work); + break; + } + ydbptr2 = ydbptr; + ydbptr = ydbptr->dom_pnext; + } +} + +void +yp_unbind (const char *indomain) +{ + pthread_mutex_lock (&ypbindlist_lock); + yp_unbind_locked (indomain); + pthread_mutex_unlock (&ypbindlist_lock); + + return; +} + +static int +__ypclnt_call (u_long prog, xdrproc_t xargs, caddr_t req, + xdrproc_t xres, caddr_t resp, dom_binding **ydb, + int print_error) +{ + enum clnt_stat result; + + assert ((*ydb)->dom_client != NULL); + + result = clnt_call ((*ydb)->dom_client, prog, + xargs, req, xres, resp, RPCTIMEOUT); + + if (result != RPC_SUCCESS) + { + /* We don't print an error message, if we try our old, + cached data. Only print this for data, which should work. */ + if (print_error) + clnt_perror ((*ydb)->dom_client, "do_ypcall: clnt_call"); + + return YPERR_RPC; + } + + return YPERR_SUCCESS; +} + +int +do_ypcall (const char *domain, u_long prog, xdrproc_t xargs, + caddr_t req, xdrproc_t xres, caddr_t resp) +{ + dom_binding *ydb; + int status; + int saved_errno = errno; + static __thread int do_ypcall_rec = 0; + + status = YPERR_YPERR; + + /* if from_yp_call is set, we have a recursion from yp_all, means to + contact the NIS server, we need to do a NIS query first. Bail out + to avoid a deadlock or crash. */ + if (from_yp_all == 1) + return YPERR_YPERR; + + /* some if something else is calling NIS again */ + if (do_ypcall_rec == 1) + return YPERR_YPERR; + + pthread_mutex_lock (&ypbindlist_lock); + do_ypcall_rec = 1; + ydb = ypbindlist; + while (ydb != NULL) + { + if (strcmp (domain, ydb->dom_domain) == 0) + { + if (__yp_bind (domain, &ydb) == 0) + { + /* Call server, print no error message, do not unbind. */ + status = __ypclnt_call (prog, xargs, req, xres, + resp, &ydb, 0); + if (status == YPERR_SUCCESS) + { + do_ypcall_rec = 0; + pthread_mutex_unlock (&ypbindlist_lock); + errno = saved_errno; + return status; + } + } + /* We use ypbindlist, and the old cached data is + invalid. unbind now and create a new binding */ + yp_unbind_locked (domain); + + break; + } + ydb = ydb->dom_pnext; + } + pthread_mutex_unlock (&ypbindlist_lock); + + /* First try with cached data failed. Now try to get + current data from the system. */ + ydb = NULL; + if (__yp_bind (domain, &ydb) == 0) + { + status = __ypclnt_call (prog, xargs, req, xres, + resp, &ydb, 1); + __yp_unbind (ydb); + } + + /* If we support binding dir data, we have a third chance: + Ask ypbind. */ + if (status != YPERR_SUCCESS) + { + ydb = calloc (1, sizeof (dom_binding)); + if (ydb != NULL && yp_bind_ypbindprog (domain, ydb) == YPERR_SUCCESS) + { + status = __ypclnt_call (prog, xargs, req, xres, + resp, &ydb, 1); + __yp_unbind (ydb); + } + else + free (ydb); + } + + do_ypcall_rec = 0; + errno = saved_errno; + + return status; +} + +/* Like do_ypcall, but translate the status value if necessary. */ +int +do_ypcall_tr (const char *domain, u_long prog, xdrproc_t xargs, + caddr_t req, xdrproc_t xres, ypresp_val *resp) +{ + int status = do_ypcall (domain, prog, xargs, req, xres, (caddr_t)resp); + if (status == YPERR_SUCCESS) + status = ypprot_err (resp->status); + return status; +} + +struct ypresp_all_data +{ + unsigned long status; + void *data; + int (*foreach) (int status, char *key, int keylen, + char *val, int vallen, char *data); +}; + +static bool_t +__xdr_ypresp_all (XDR *xdrs, struct ypresp_all_data *objp) +{ + while (1) + { + struct ypresp_all resp; + + memset (&resp, '\0', sizeof (struct ypresp_all)); + if (!xdr_ypresp_all (xdrs, &resp)) + { + xdr_free ((xdrproc_t) xdr_ypresp_all, (char *) &resp); + objp->status = YP_YPERR; + return FALSE; + } + if (resp.more == 0) + { + xdr_free ((xdrproc_t) xdr_ypresp_all, (char *) &resp); + objp->status = YP_NOMORE; + return TRUE; + } + + switch (resp.ypresp_all_u.val.status) + { + case YP_TRUE: + { + char key[resp.ypresp_all_u.val.keydat.keydat_len + 1]; + char val[resp.ypresp_all_u.val.valdat.valdat_len + 1]; + int keylen = resp.ypresp_all_u.val.keydat.keydat_len; + int vallen = resp.ypresp_all_u.val.valdat.valdat_len; + + /* We are not allowed to modify the key and val data. + But we are allowed to add data behind the buffer, + if we don't modify the length. So add an extra NUL + character to avoid trouble with broken code. */ + objp->status = YP_TRUE; + memcpy (key, resp.ypresp_all_u.val.keydat.keydat_val, + keylen); + key[keylen] = '\0'; + memcpy (val, resp.ypresp_all_u.val.valdat.valdat_val, + vallen); + val[vallen] = '\0'; + + xdr_free ((xdrproc_t) xdr_ypresp_all, (char *) &resp); + if ((*objp->foreach) (objp->status, key, keylen, + val, vallen, objp->data)) + return TRUE; + } + break; + default: + objp->status = resp.ypresp_all_u.val.status; + xdr_free ((xdrproc_t) xdr_ypresp_all, (char *) &resp); + /* Sun says we don't need to make this call, but must return + immediately. Since Solaris makes this call, we will call + the callback function, too. */ + (*objp->foreach) (objp->status, NULL, 0, NULL, 0, objp->data); + return TRUE; + } + } +} + +int +yp_all (const char *indomain, const char *inmap, + const struct ypall_callback *incallback) +{ + struct ypreq_nokey req; + dom_binding *ydb = NULL; + char *server = NULL; + int try, res; + enum clnt_stat result; + CLIENT *clnt; + struct ypresp_all_data data; + int saved_errno = errno; + + if (indomain == NULL || indomain[0] == '\0' + || inmap == NULL || inmap[0] == '\0') + return YPERR_BADARGS; + + try = 0; + res = YPERR_YPERR; + + /* We are called by our self, which means something is resolved + via NIS which is necessary to contact the NIS server */ + if (from_yp_all == 1) + return YPERR_YPERR; + + pthread_mutex_lock (&ypbindlist_lock); + from_yp_all = 1; /* We are inside a lock, tell other functions of + the same thread. */ + + while (try < MAXTRIES && res != YPERR_SUCCESS) + { + if (__yp_bind (indomain, &ydb) != 0) + { + res = YPERR_DOMAIN; + goto out; + } + + server = strdup (ydb->server); + + /* We don't need the UDP connection anymore. */ + __yp_unbind (ydb); + ydb = NULL; + + clnt = clnt_create (server, YPPROG, YPVERS, "tcp"); + if (clnt == NULL) + { + res = YPERR_PMAP; + goto out; + } + req.domain = (char *) indomain; + req.map = (char *) inmap; + + data.foreach = incallback->foreach; + data.data = (void *) incallback->data; + + result = clnt_call (clnt, YPPROC_ALL, (xdrproc_t) xdr_ypreq_nokey, + (caddr_t) &req, (xdrproc_t) __xdr_ypresp_all, + (caddr_t) &data, RPCTIMEOUT); + + if (result != RPC_SUCCESS) + { + /* Print the error message only on the last try. */ + if (try == MAXTRIES - 1) + clnt_perror (clnt, "yp_all: clnt_call"); + res = YPERR_RPC; + } + else + res = YPERR_SUCCESS; + + clnt_destroy (clnt); + + if (res == YPERR_SUCCESS && data.status != YP_NOMORE) + { + res = ypprot_err (data.status); + goto out; + } + ++try; + } + + out: + from_yp_all = 0; + pthread_mutex_unlock (&ypbindlist_lock); + + if (server) + free (server); + + errno = saved_errno; + + return res; +} diff --git a/src/internal.h b/src/internal.h new file mode 100644 index 0000000..68236f6 --- /dev/null +++ b/src/internal.h @@ -0,0 +1,24 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _INTERNAL_H_ +#define _INTERNAL_H_ + +extern int do_ypcall (const char *domain, u_long prog, xdrproc_t xargs, + caddr_t req, xdrproc_t xres, caddr_t resp); +extern int do_ypcall_tr (const char *domain, u_long prog, xdrproc_t xargs, + caddr_t req, xdrproc_t xres, struct ypresp_val *resp); +extern int yp_maplist (const char *, struct ypmaplist **); +#endif diff --git a/src/libc-lock.h b/src/libc-lock.h new file mode 100644 index 0000000..2a85fa1 --- /dev/null +++ b/src/libc-lock.h @@ -0,0 +1,28 @@ +#ifndef _LIBC_LOCK_H +#define _LIBC_LOCK_H 1 + +#include + +#define __libc_lock_define_initialized(CLASS,NAME) \ + CLASS pthread_mutex_t NAME = PTHREAD_MUTEX_INITIALIZER; + +#define __libc_once_define(CLASS, NAME) \ + CLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; + +#define __libc_lock_lock(NAME) \ + pthread_mutex_lock (&(NAME)) + +#define __libc_lock_unlock(NAME) \ + pthread_mutex_unlock (&(NAME)) + +/* Call handler iff the first call. */ +#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \ + do { \ + if ((ONCE_CONTROL) == 0) { \ + INIT_FUNCTION (); \ + (ONCE_CONTROL) = 1; \ + } \ + } while (0) + + +#endif /* libc-lock.h */ diff --git a/src/libnsl.map b/src/libnsl.map new file mode 100644 index 0000000..d44585b --- /dev/null +++ b/src/libnsl.map @@ -0,0 +1,94 @@ +LIBNSL_1.0 { + global: + # YP/XDR functions: + xdr_domainname; + xdr_ypbind2_binding; + xdr_ypbind2_resp; + xdr_ypbind2_setdom; + xdr_ypbind3_binding; + xdr_ypbind3_resp; + xdr_ypbind3_setdom; + xdr_ypbind_oldsetdom; + xdr_ypbind_resptype; + xdr_ypmap_parms; + xdr_ypmaplist; + xdr_yppushresp_xfr; + xdr_ypreq_key; + xdr_ypreq_newxfr; + xdr_ypreq_nokey; + xdr_ypreq_xfr; + xdr_ypresp_all; + xdr_ypresp_key_val; + xdr_ypresp_maplist; + xdr_ypresp_master; + xdr_ypresp_order; + xdr_ypresp_val; + xdr_ypresp_xfr; + xdr_ypstat; + xdr_ypxfrstat; + yp_all; + yp_bind; + yp_first; + yp_get_default_domain; + yp_maplist; + yp_master; + yp_match; + yp_next; + yp_order; + yp_unbind; + ypbinderr_string; + yperr_string; + ypprot_err; + + # NIS+ functions + nis_add; nis_add_entry; nis_addmember; + nis_checkpoint; nis_clone_directory; nis_clone_object; + nis_clone_result; nis_creategroup; nis_destroy_object; + nis_destroygroup; nis_dir_cmp; nis_domain_of; + nis_domain_of_r; nis_first_entry; nis_free_directory; + nis_free_object; nis_free_request; nis_freenames; + nis_freeresult; nis_freeservlist; nis_freetags; + nis_getnames; nis_getservlist; nis_ismember; + nis_leaf_of; nis_leaf_of_r; nis_lerror; + nis_list; nis_local_directory; nis_local_group; + nis_local_host; nis_local_principal; nis_lookup; + nis_mkdir; nis_modify; nis_modify_entry; + nis_name_of; nis_name_of_r; nis_next_entry; + nis_perror; nis_ping; nis_print_directory; + nis_print_entry; nis_print_group; nis_print_group_entry; + nis_print_link; nis_print_object; nis_print_result; + nis_print_rights; nis_print_table; nis_read_obj; + nis_remove; nis_remove_entry; nis_removemember; + nis_rmdir; nis_servstate; nis_sperrno; + nis_sperror; nis_sperror_r; nis_stats; + nis_verifygroup; nis_write_obj; + xdr_cback_data; xdr_obj_p; + + local: + *; +}; + +LIBNSL_1.0.1 { + global: + xdr_keydat; + xdr_valdat; + xdr_ypcall; +} LIBNSL_1.0; + +LIBNSL_1.0.2 { + global: + taddr2host; + taddr2ipstr; + taddr2port; +} LIBNSL_1.0.1; + +LIBNSL_PRIVATE { + global: + __create_ib_request; + __do_niscall3; + __follow_path; + __nisbind_destroy; + __prepare_niscall; + _xdr_ib_request; + _xdr_nis_result; +}; diff --git a/src/nisplus/nis_add.c b/src/nisplus/nis_add.c new file mode 100644 index 0000000..af3b1e4 --- /dev/null +++ b/src/nisplus/nis_add.c @@ -0,0 +1,76 @@ +/* Copyright (C) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "nis_intern.h" +#include "nis_xdr.h" + +nis_result * +nis_add (const_nis_name name, const nis_object *obj2) +{ + nis_object obj; + nis_result *res; + nis_error status; + struct ns_request req; + size_t namelen = strlen (name); + char buf1 [namelen + 20]; + char buf4 [namelen + 20]; + + res = calloc (1, sizeof (nis_result)); + if (res == NULL) + return NULL; + + req.ns_name = (char *)name; + + memcpy (&obj, obj2, sizeof (nis_object)); + + if (obj.zo_name == NULL || obj.zo_name[0] == '\0') + obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1)); + + if (obj.zo_owner == NULL || obj.zo_owner[0] == '\0') + obj.zo_owner = nis_local_principal (); + + if (obj.zo_group == NULL || obj.zo_group[0] == '\0') + obj.zo_group = nis_local_group (); + + obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4)); + + req.ns_object.ns_object_val = nis_clone_object (&obj, NULL); + if (req.ns_object.ns_object_val == NULL) + { + NIS_RES_STATUS (res) = NIS_NOMEMORY; + return res; + } + req.ns_object.ns_object_len = 1; + + status = __do_niscall (req.ns_object.ns_object_val[0].zo_domain, + NIS_ADD, (xdrproc_t) _xdr_ns_request, + (caddr_t) &req, (xdrproc_t) _xdr_nis_result, + (caddr_t) res, MASTER_ONLY, NULL); + if (status != NIS_SUCCESS) + NIS_RES_STATUS (res) = status; + + nis_destroy_object (req.ns_object.ns_object_val); + + return res; +} diff --git a/src/nisplus/nis_addmember.c b/src/nisplus/nis_addmember.c new file mode 100644 index 0000000..71ac3d5 --- /dev/null +++ b/src/nisplus/nis_addmember.c @@ -0,0 +1,97 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +nis_error +nis_addmember (const_nis_name member, const_nis_name group) +{ + if (group != NULL && group[0] != '\0') + { + size_t grouplen = strlen (group); + char buf[grouplen + 14 + NIS_MAXNAMELEN]; + char domainbuf[grouplen + 2]; + nis_result *res, *res2; + nis_error status; + char *cp, *cp2; + + cp = nis_leaf_of_r (group, buf, sizeof (buf) - 1); + cp += strlen (cp); + cp = stpcpy (cp, ".groups_dir"); + cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); + if (cp2 != NULL && cp2[0] != '\0') + { + *cp++ = '.'; + stpcpy (cp, cp2); + } + res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME); + if (NIS_RES_STATUS (res) != NIS_SUCCESS) + { + status = NIS_RES_STATUS (res); + nis_freeresult (res); + return status; + } + if (NIS_RES_NUMOBJ (res) != 1 + || __type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ) + { + nis_freeresult (res); + return NIS_INVALIDOBJ; + } + + u_int gr_members_len + = NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len; + + nis_name *new_gr_members_val + = realloc (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val, + (gr_members_len + 1) * sizeof (nis_name)); + if (new_gr_members_val == NULL) + goto nomem_out; + + NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val + = new_gr_members_val; + + new_gr_members_val[gr_members_len] = strdup (member); + if (new_gr_members_val[gr_members_len] == NULL) + { + nomem_out: + nis_freeresult (res); + return NIS_NOMEMORY; + } + ++NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len; + + /* Check the buffer bounds are not exceeded. */ + assert (strlen (NIS_RES_OBJECT(res)->zo_name) + 1 < grouplen + 14); + cp = stpcpy (buf, NIS_RES_OBJECT(res)->zo_name); + *cp++ = '.'; + strncpy (cp, NIS_RES_OBJECT (res)->zo_domain, NIS_MAXNAMELEN); + res2 = nis_modify (buf, NIS_RES_OBJECT (res)); + status = NIS_RES_STATUS (res2); + nis_freeresult (res); + nis_freeresult (res2); + + return status; + } + else + return NIS_FAIL; +} diff --git a/src/nisplus/nis_call.c b/src/nisplus/nis_call.c new file mode 100644 index 0000000..798fbf1 --- /dev/null +++ b/src/nisplus/nis_call.c @@ -0,0 +1,845 @@ +/* Copyright (C) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libc-lock.h" +#include "nis_intern.h" +#include "nis_xdr.h" + +static const struct timeval RPCTIMEOUT = {10, 0}; +static const struct timeval UDPTIMEOUT = {5, 0}; + +extern u_short __pmap_getnisport (struct sockaddr_in *address, u_long program, + u_long version, u_int protocol); + +unsigned long int +inetstr2int (const char *str) +{ + size_t i, j = 0; + + for (i = 0; str[i] != '\0'; ++i) + if (str[i] == '.' && __builtin_expect (++j == 4, 0)) + { + char buffer[i + 1]; + buffer[i] = '\0'; + return inet_addr (memcpy (buffer, str, i)); + } + + return inet_addr (str); +} + +void +__nisbind_destroy (dir_binding *bind) +{ + if (bind->clnt != NULL) + { + if (bind->use_auth) + auth_destroy (bind->clnt->cl_auth); + clnt_destroy (bind->clnt); + } +} + +nis_error +__nisbind_next (dir_binding *bind) +{ + u_int j; + + if (bind->clnt != NULL) + { + if (bind->use_auth) + auth_destroy (bind->clnt->cl_auth); + clnt_destroy (bind->clnt); + bind->clnt = NULL; + } + + if (bind->trys >= bind->server_len) + return NIS_FAIL; + + for (j = bind->current_ep + 1; + j < bind->server_val[bind->server_used].ep.ep_len; ++j) + if (strcmp (bind->server_val[bind->server_used].ep.ep_val[j].family, + "inet") == 0) + if (bind->server_val[bind->server_used].ep.ep_val[j].proto[0] == '-') + { + bind->current_ep = j; + return NIS_SUCCESS; + } + + ++bind->trys; + ++bind->server_used; + if (bind->server_used >= bind->server_len) + bind->server_used = 0; + + for (j = 0; j < bind->server_val[bind->server_used].ep.ep_len; ++j) + if (strcmp (bind->server_val[bind->server_used].ep.ep_val[j].family, + "inet") == 0) + if (bind->server_val[bind->server_used].ep.ep_val[j].proto[0] == '-') + { + bind->current_ep = j; + return NIS_SUCCESS; + } + + return NIS_FAIL; +} + +static struct ckey_cache_entry +{ + struct in_addr inaddr; + in_port_t port; + unsigned int protocol; + des_block ckey; +} *ckey_cache; +static size_t ckey_cache_size; +static size_t ckey_cache_allocated; +static pid_t ckey_cache_pid; +static uid_t ckey_cache_euid; +__libc_lock_define_initialized (static, ckey_cache_lock) + +static bool_t +get_ckey (des_block *ckey, struct sockaddr_in *addr, unsigned int protocol) +{ + size_t i; + pid_t pid = getpid (); + uid_t euid = geteuid (); + bool_t ret = FALSE; + + __libc_lock_lock (ckey_cache_lock); + + if (ckey_cache_pid != pid || ckey_cache_euid != euid) + { + ckey_cache_size = 0; + ckey_cache_pid = pid; + ckey_cache_euid = euid; + } + + for (i = 0; i < ckey_cache_size; ++i) + if (ckey_cache[i].port == addr->sin_port + && ckey_cache[i].protocol == protocol + && memcmp (&ckey_cache[i].inaddr, &addr->sin_addr, + sizeof (addr->sin_addr)) == 0) + { + *ckey = ckey_cache[i].ckey; + ret = TRUE; + break; + } + + if (!ret && key_gendes (ckey) >= 0) + { + ret = TRUE; + /* Don't grow the cache indefinitely. */ + if (ckey_cache_size == 256) + ckey_cache_size = 0; + if (ckey_cache_size == ckey_cache_allocated) + { + size_t size = ckey_cache_allocated ? ckey_cache_allocated * 2 : 16; + struct ckey_cache_entry *new_cache + = realloc (ckey_cache, size * sizeof (*ckey_cache)); + if (new_cache != NULL) + { + ckey_cache = new_cache; + ckey_cache_allocated = size; + } + } + ckey_cache[ckey_cache_size].inaddr = addr->sin_addr; + ckey_cache[ckey_cache_size].port = addr->sin_port; + ckey_cache[ckey_cache_size].protocol = protocol; + ckey_cache[ckey_cache_size++].ckey = *ckey; + } + + __libc_lock_unlock (ckey_cache_lock); + return ret; +} + +nis_error +__nisbind_connect (dir_binding *dbp) +{ + nis_server *serv; + u_short port; + + if (dbp == NULL) + return NIS_FAIL; + + serv = &dbp->server_val[dbp->server_used]; + + memset (&dbp->addr, '\0', sizeof (dbp->addr)); + dbp->addr.sin_family = AF_INET; + + dbp->addr.sin_addr.s_addr = + inetstr2int (serv->ep.ep_val[dbp->current_ep].uaddr); + + if (dbp->addr.sin_addr.s_addr == INADDR_NONE) + return NIS_FAIL; + + /* Check, if the host is online and rpc.nisd is running. Much faster + then the clnt*_create functions: */ + port = __pmap_getnisport (&dbp->addr, NIS_PROG, NIS_VERSION, + dbp->use_udp ? IPPROTO_UDP : IPPROTO_TCP); + if (port == 0) + return NIS_RPCERROR; + + dbp->addr.sin_port = htons (port); + dbp->socket = RPC_ANYSOCK; + if (dbp->use_udp) + dbp->clnt = clntudp_create (&dbp->addr, NIS_PROG, NIS_VERSION, + UDPTIMEOUT, &dbp->socket); + else + dbp->clnt = clnttcp_create (&dbp->addr, NIS_PROG, NIS_VERSION, + &dbp->socket, 0, 0); + + if (dbp->clnt == NULL) + return NIS_RPCERROR; + + clnt_control (dbp->clnt, CLSET_TIMEOUT, (caddr_t) &RPCTIMEOUT); + /* If the program exists, close the socket */ + if (fcntl (dbp->socket, F_SETFD, 1) == -1) + perror ("fcntl: F_SETFD"); + + if (dbp->use_auth) + { + if (serv->key_type == NIS_PK_DH) + { + char netname[MAXNETNAMELEN + 1]; + char *p; + des_block ckey; + + p = stpcpy (netname, "unix@"); + strncpy (p, serv->name, MAXNETNAMELEN - 5); + netname[MAXNETNAMELEN] = '\0'; + dbp->clnt->cl_auth = NULL; + if (get_ckey (&ckey, &dbp->addr, + dbp->use_udp ? IPPROTO_UDP : IPPROTO_TCP)) + dbp->clnt->cl_auth = + authdes_pk_create (netname, &serv->pkey, 300, NULL, &ckey); + if (!dbp->clnt->cl_auth) + dbp->clnt->cl_auth = authunix_create_default (); + } + else + dbp->clnt->cl_auth = authunix_create_default (); + } + + return NIS_SUCCESS; +} + +nis_error +__nisbind_create (dir_binding *dbp, const nis_server *serv_val, + unsigned int serv_len, unsigned int server_used, + unsigned int current_ep, unsigned int flags) +{ + dbp->clnt = NULL; + + dbp->server_len = serv_len; + dbp->server_val = (nis_server *)serv_val; + + if (flags & USE_DGRAM) + dbp->use_udp = TRUE; + else + dbp->use_udp = FALSE; + + if (flags & NO_AUTHINFO) + dbp->use_auth = FALSE; + else + dbp->use_auth = TRUE; + + if (flags & MASTER_ONLY) + dbp->master_only = TRUE; + else + dbp->master_only = FALSE; + + /* We try the first server */ + dbp->trys = 1; + + dbp->class = -1; + if (server_used == ~0) + { + if (__nis_findfastest (dbp) < 1) + return NIS_NAMEUNREACHABLE; + } + else + { + dbp->server_used = server_used; + dbp->current_ep = current_ep; + } + + return NIS_SUCCESS; +} + +/* __nisbind_connect (dbp) must be run before calling this function ! + So we could use the same binding twice */ +nis_error +__do_niscall3 (dir_binding *dbp, u_long prog, xdrproc_t xargs, caddr_t req, + xdrproc_t xres, caddr_t resp, unsigned int flags, nis_cb *cb) +{ + enum clnt_stat result; + nis_error retcode; + + if (dbp == NULL) + return NIS_NAMEUNREACHABLE; + + do + { + again: + result = clnt_call (dbp->clnt, prog, xargs, req, xres, resp, RPCTIMEOUT); + + if (result != RPC_SUCCESS) + retcode = NIS_RPCERROR; + else + { + switch (prog) + { + case NIS_IBLIST: + if ((((nis_result *)resp)->status == NIS_CBRESULTS) && + (cb != NULL)) + { + __nis_do_callback (dbp, &((nis_result *) resp)->cookie, cb); + break; + } + /* Yes, the missing break is correct. If we doesn't have to + start a callback, look if we have to search another server */ + case NIS_LOOKUP: + case NIS_ADD: + case NIS_MODIFY: + case NIS_REMOVE: + case NIS_IBADD: + case NIS_IBMODIFY: + case NIS_IBREMOVE: + case NIS_IBFIRST: + case NIS_IBNEXT: + if (((nis_result *)resp)->status == NIS_SYSTEMERROR + || ((nis_result *)resp)->status == NIS_NOSUCHNAME + || ((nis_result *)resp)->status == NIS_NOT_ME) + { + next_server: + if (__nisbind_next (dbp) == NIS_SUCCESS) + { + while (__nisbind_connect (dbp) != NIS_SUCCESS) + { + if (__nisbind_next (dbp) != NIS_SUCCESS) + return NIS_SUCCESS; + } + } + else + break; /* No more servers to search in */ + goto again; + } + break; + case NIS_FINDDIRECTORY: + if (((fd_result *)resp)->status == NIS_SYSTEMERROR + || ((fd_result *)resp)->status == NIS_NOSUCHNAME + || ((fd_result *)resp)->status == NIS_NOT_ME) + goto next_server; + break; + case NIS_DUMPLOG: /* log_result */ + case NIS_DUMP: + if (((log_result *)resp)->lr_status == NIS_SYSTEMERROR + || ((log_result *)resp)->lr_status == NIS_NOSUCHNAME + || ((log_result *)resp)->lr_status == NIS_NOT_ME) + goto next_server; + break; + default: + break; + } + retcode = NIS_SUCCESS; + } + } + while ((flags & HARD_LOOKUP) && retcode == NIS_RPCERROR); + + return retcode; +} + +nis_error +__do_niscall2 (const nis_server *server, u_int server_len, u_long prog, + xdrproc_t xargs, caddr_t req, xdrproc_t xres, caddr_t resp, + unsigned int flags, nis_cb *cb) +{ + dir_binding dbp; + nis_error status; + + if (flags & MASTER_ONLY) + server_len = 1; + + status = __nisbind_create (&dbp, server, server_len, ~0, ~0, flags); + if (status != NIS_SUCCESS) + return status; + + while (__nisbind_connect (&dbp) != NIS_SUCCESS) + if (__nisbind_next (&dbp) != NIS_SUCCESS) + return NIS_NAMEUNREACHABLE; + + status = __do_niscall3 (&dbp, prog, xargs, req, xres, resp, flags, cb); + + __nisbind_destroy (&dbp); + + return status; + +} + +static directory_obj * +rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status) +{ + fd_result *fd_res; + XDR xdrs; + + switch (nis_dir_cmp (name, dir->do_name)) + { + case SAME_NAME: + *status = NIS_SUCCESS; + return dir; + case NOT_SEQUENTIAL: + /* NOT_SEQUENTIAL means, go one up and try it there ! */ + case HIGHER_NAME: + { /* We need data from a parent domain */ + directory_obj *obj; + const char *ndomain = __nis_domain_of (dir->do_name); + + /* The root server of our domain is a replica of the parent + domain ! (Now I understand why a root server must be a + replica of the parent domain) */ + fd_res = __nis_finddirectory (dir, ndomain); + if (fd_res == NULL) + { + nis_free_directory (dir); + *status = NIS_NOMEMORY; + return NULL; + } + *status = fd_res->status; + if (fd_res->status != NIS_SUCCESS) + { + /* Try the current directory obj, maybe it works */ + __free_fdresult (fd_res); + return dir; + } + nis_free_directory (dir); + obj = calloc (1, sizeof (directory_obj)); + if (obj == NULL) + { + __free_fdresult (fd_res); + *status = NIS_NOMEMORY; + return NULL; + } + xdrmem_create (&xdrs, fd_res->dir_data.dir_data_val, + fd_res->dir_data.dir_data_len, XDR_DECODE); + _xdr_directory_obj (&xdrs, obj); + xdr_destroy (&xdrs); + __free_fdresult (fd_res); + + /* We have found a NIS+ server serving ndomain, now + let us search for "name" */ + return rec_dirsearch (name, obj, status); + } + break; + case LOWER_NAME: + { + directory_obj *obj; + size_t namelen = strlen (name); + char leaf[namelen + 3]; + char domain[namelen + 3]; + const char *ndomain; + char *cp; + + strcpy (domain, name); + + do + { + if (domain[0] == '\0') + { + nis_free_directory (dir); + return NULL; + } + nis_leaf_of_r (domain, leaf, sizeof (leaf)); + ndomain = __nis_domain_of (domain); + memmove (domain, ndomain, strlen (ndomain) + 1); + } + while (nis_dir_cmp (domain, dir->do_name) != SAME_NAME); + + cp = (char *)leaf + strlen (leaf); + *cp++ = '.'; + strcpy (cp, domain); + + fd_res = __nis_finddirectory (dir, leaf); + if (fd_res == NULL) + { + nis_free_directory (dir); + *status = NIS_NOMEMORY; + return NULL; + } + *status = fd_res->status; + if (fd_res->status != NIS_SUCCESS) + { + /* Try the current directory object, maybe it works */ + __free_fdresult (fd_res); + return dir; + } + nis_free_directory (dir); + obj = calloc (1, sizeof(directory_obj)); + if (obj == NULL) + { + __free_fdresult (fd_res); + *status = NIS_NOMEMORY; + return NULL; + } + xdrmem_create (&xdrs, fd_res->dir_data.dir_data_val, + fd_res->dir_data.dir_data_len, XDR_DECODE); + _xdr_directory_obj (&xdrs, obj); + xdr_destroy (&xdrs); + __free_fdresult (fd_res); + /* We have found a NIS+ server serving ndomain, now + let us search for "name" */ + return rec_dirsearch (name, obj, status); + } + break; + case BAD_NAME: + nis_free_directory (dir); + *status = NIS_BADNAME; + return NULL; + } + nis_free_directory (dir); + *status = NIS_FAIL; + return NULL; +} + +/* We try to query the current server for the searched object, + maybe he know about it ? */ +static directory_obj * +first_shoot (const_nis_name name, directory_obj *dir) +{ + directory_obj *obj = NULL; + fd_result *fd_res; + XDR xdrs; + + if (nis_dir_cmp (name, dir->do_name) == SAME_NAME) + return dir; + + fd_res = __nis_finddirectory (dir, name); + if (fd_res == NULL) + return NULL; + if (fd_res->status == NIS_SUCCESS + && (obj = calloc (1, sizeof (directory_obj))) != NULL) + { + xdrmem_create (&xdrs, fd_res->dir_data.dir_data_val, + fd_res->dir_data.dir_data_len, XDR_DECODE); + _xdr_directory_obj (&xdrs, obj); + xdr_destroy (&xdrs); + + if (strcmp (dir->do_name, obj->do_name) != 0) + { + nis_free_directory (obj); + obj = NULL; + } + } + + __free_fdresult (fd_res); + + if (obj != NULL) + nis_free_directory (dir); + + return obj; +} + +static struct nis_server_cache +{ + int search_parent; + int uses; + unsigned int size; + unsigned int server_used; + unsigned int current_ep; + time_t expires; + char name[]; +} *nis_server_cache[16]; +static time_t nis_cold_start_mtime; +__libc_lock_define_initialized (static, nis_server_cache_lock) + +static directory_obj * +nis_server_cache_search (const_nis_name name, int search_parent, + unsigned int *server_used, unsigned int *current_ep, + struct timeval *now) +{ + directory_obj *ret = NULL; + int i; + char *addr; + XDR xdrs; + struct stat64 st; + + int saved_errno = errno; + if (stat64 ("/var/nis/NIS_COLD_START", &st) < 0) + st.st_mtime = nis_cold_start_mtime + 1; + errno = saved_errno; + + __libc_lock_lock (nis_server_cache_lock); + + for (i = 0; i < 16; ++i) + if (nis_server_cache[i] == NULL) + continue; + else if (st.st_mtime != nis_cold_start_mtime + || now->tv_sec > nis_server_cache[i]->expires) + { + free (nis_server_cache[i]); + nis_server_cache[i] = NULL; + } + else if (nis_server_cache[i]->search_parent == search_parent + && strcmp (nis_server_cache[i]->name, name) == 0) + { + ret = calloc (1, sizeof (directory_obj)); + if (ret == NULL) + break; + + addr = nis_server_cache[i]->name; + addr += strlen (addr) + 8; + addr = (char *) ((uintptr_t) addr & ~(uintptr_t) 7); + xdrmem_create (&xdrs, addr, nis_server_cache[i]->size, XDR_DECODE); + if (!_xdr_directory_obj (&xdrs, ret)) + { + xdr_destroy (&xdrs); + free (ret); + ret = NULL; + free (nis_server_cache[i]); + nis_server_cache[i] = NULL; + break; + } + xdr_destroy (&xdrs); + *server_used = nis_server_cache[i]->server_used; + *current_ep = nis_server_cache[i]->current_ep; + break; + } + + nis_cold_start_mtime = st.st_mtime; + + __libc_lock_unlock (nis_server_cache_lock); + return ret; +} + +static void +nis_server_cache_add (const_nis_name name, int search_parent, + directory_obj *dir, unsigned int server_used, + unsigned int current_ep, struct timeval *now) +{ + struct nis_server_cache **loc; + struct nis_server_cache *new; + struct nis_server_cache *old; + int i; + char *addr; + unsigned int size; + XDR xdrs; + + if (dir == NULL) + return; + + size = xdr_sizeof ((xdrproc_t) _xdr_directory_obj, (char *) dir); + new = calloc (1, sizeof (*new) + strlen (name) + 8 + size); + if (new == NULL) + return; + new->search_parent = search_parent; + new->uses = 1; + new->expires = now->tv_sec + dir->do_ttl; + new->size = size; + new->server_used = server_used; + new->current_ep = current_ep; + addr = stpcpy (new->name, name) + 8; + addr = (char *) ((uintptr_t) addr & ~(uintptr_t) 7); + + xdrmem_create(&xdrs, addr, size, XDR_ENCODE); + if (!_xdr_directory_obj (&xdrs, dir)) + { + xdr_destroy (&xdrs); + free (new); + return; + } + xdr_destroy (&xdrs); + + __libc_lock_lock (nis_server_cache_lock); + + /* Choose which entry should be evicted from the cache. */ + loc = &nis_server_cache[0]; + if (*loc != NULL) + { + for (i = 1; i < 16; ++i) + if (nis_server_cache[i] == NULL) + { + loc = &nis_server_cache[i]; + break; + } + else if ((*loc)->uses > nis_server_cache[i]->uses + || ((*loc)->uses == nis_server_cache[i]->uses + && (*loc)->expires > nis_server_cache[i]->expires)) + { + loc = &nis_server_cache[i]; + } + } + old = *loc; + *loc = new; + + __libc_lock_unlock (nis_server_cache_lock); + free (old); +} + +nis_error +__nisfind_server (const_nis_name name, int search_parent, + directory_obj **dir, dir_binding *dbp, unsigned int flags) +{ + nis_error result = NIS_SUCCESS; + nis_error status; + directory_obj *obj; + struct timeval now; + unsigned int server_used = ~0; + unsigned int current_ep = ~0; + + if (name == NULL) + return NIS_BADNAME; + + if (*dir != NULL) + return NIS_SUCCESS; + + (void) gettimeofday (&now, NULL); + + if ((flags & NO_CACHE) == 0) + *dir = nis_server_cache_search (name, search_parent, &server_used, + ¤t_ep, &now); + if (*dir != NULL) + { + unsigned int server_len = (*dir)->do_servers.do_servers_len; + if (flags & MASTER_ONLY) + { + server_len = 1; + if (server_used != 0) + { + server_used = ~0; + current_ep = ~0; + } + } + result = __nisbind_create (dbp, (*dir)->do_servers.do_servers_val, + server_len, server_used, current_ep, flags); + if (result != NIS_SUCCESS) + { + nis_free_directory (*dir); + *dir = NULL; + } + return result; + } + + int saved_errno = errno; + *dir = readColdStartFile (); + errno = saved_errno; + if (*dir == NULL) + /* No /var/nis/NIS_COLD_START->no NIS+ installed. */ + return NIS_UNAVAIL; + + /* Try at first, if servers in "dir" know our object */ + const char *search_name = name; + if (search_parent) + search_name = __nis_domain_of (name); + obj = first_shoot (search_name, *dir); + if (obj == NULL) + { + obj = rec_dirsearch (search_name, *dir, &status); + if (obj == NULL) + result = status; + } + + if (result == NIS_SUCCESS) + { + unsigned int server_len = obj->do_servers.do_servers_len; + if (flags & MASTER_ONLY) + server_len = 1; + result = __nisbind_create (dbp, obj->do_servers.do_servers_val, + server_len, ~0, ~0, flags); + if (result == NIS_SUCCESS) + { + if ((flags & MASTER_ONLY) == 0 + || obj->do_servers.do_servers_len == 1) + { + server_used = dbp->server_used; + current_ep = dbp->current_ep; + } + if ((flags & NO_CACHE) == 0) + nis_server_cache_add (name, search_parent, obj, + server_used, current_ep, &now); + } + else + { + nis_free_directory (obj); + obj = NULL; + } + } + + *dir = obj; + + return result; +} + + +nis_error +__prepare_niscall (const_nis_name name, directory_obj **dirp, + dir_binding *bptrp, unsigned int flags) +{ + nis_error retcode = __nisfind_server (name, 1, dirp, bptrp, flags); + if (retcode != NIS_SUCCESS) + return retcode; + + do + if (__nisbind_connect (bptrp) == NIS_SUCCESS) + return NIS_SUCCESS; + while (__nisbind_next (bptrp) == NIS_SUCCESS); + + __nisbind_destroy (bptrp); + memset (bptrp, '\0', sizeof (*bptrp)); + + retcode = NIS_NAMEUNREACHABLE; + nis_free_directory (*dirp); + *dirp = NULL; + + return retcode; +} + +nis_error +__do_niscall (const_nis_name name, u_long prog, xdrproc_t xargs, + caddr_t req, xdrproc_t xres, caddr_t resp, unsigned int flags, + nis_cb *cb) +{ + dir_binding bptr; + directory_obj *dir = NULL; + int saved_errno = errno; + + nis_error retcode = __prepare_niscall (name, &dir, &bptr, flags); + if (retcode == NIS_SUCCESS) + { + retcode = __do_niscall3 (&bptr, prog, xargs, req, xres, resp, flags, cb); + + __nisbind_destroy (&bptr); + + nis_free_directory (dir); + } + + errno = saved_errno; + + return retcode; +} diff --git a/src/nisplus/nis_callback.c b/src/nisplus/nis_callback.c new file mode 100644 index 0000000..81b6695 --- /dev/null +++ b/src/nisplus/nis_callback.c @@ -0,0 +1,401 @@ +/* Copyright (C) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libc-lock.h" +#include "nis_intern.h" +#include "nis_xdr.h" +#include + +#ifndef _ +#define _(String) gettext (String) +#endif + +#ifndef TEMP_FAILURE_RETRY +# define TEMP_FAILURE_RETRY(expression) \ + (__extension__ \ + ({ long int __result; \ + do __result = (long int) (expression); \ + while (__result == -1L && errno == EINTR); \ + __result; })) +#endif + + +/* Sorry, we are not able to make this threadsafe. Stupid. But some + functions doesn't send us a nis_result obj, so we don't have a + cookie. Maybe we could use keys for threads ? Have to learn more + about pthreads -- kukuk@vt.uni-paderborn.de */ + +static nis_cb *data; + +__libc_lock_define_initialized (static, callback_lock) + + +#if 0 +static char * +__nis_getpkey(const char *sname) +{ + char buf[(strlen (sname) + 1) * 2 + 40]; + char pkey[HEXKEYBYTES + 1]; + char *cp, *domain; + nis_result *res; + unsigned int len = 0; + + domain = strchr (sname, '.'); + if (domain == NULL) + return NULL; + + /* Remove prefixing dot */ + ++domain; + + cp = stpcpy (buf, "[cname="); + cp = stpcpy (cp, sname); + cp = stpcpy (cp, ",auth_type=DES],cred.org_dir."); + cp = stpcpy (cp, domain); + + res = nis_list (buf, USE_DGRAM|NO_AUTHINFO|FOLLOW_LINKS|FOLLOW_PATH, + NULL, NULL); + + if (res == NULL) + return NULL; + + if (NIS_RES_STATUS (res) != NIS_SUCCESS) + { + nis_freeresult (res); + return NULL; + } + + len = ENTRY_LEN(NIS_RES_OBJECT(res), 3); + strncpy (pkey, ENTRY_VAL(NIS_RES_OBJECT(res), 3), len); + pkey[len] = '\0'; + cp = strchr (pkey, ':'); + if (cp != NULL) + *cp = '\0'; + + nis_freeresult (res); + + return strdup (pkey); +} +#endif + +static void +cb_prog_1 (struct svc_req *rqstp, SVCXPRT *transp) +{ + union + { + cback_data cbproc_receive_1_arg; + nis_error cbproc_error_1_arg; + } + argument; + char *result; + xdrproc_t xdr_argument, xdr_result; + bool_t bool_result; + + switch (rqstp->rq_proc) + { + case NULLPROC: + svc_sendreply (transp, (xdrproc_t) xdr_void, (char *) NULL); + return; + + case CBPROC_RECEIVE: + { + unsigned int i; + + xdr_argument = (xdrproc_t) xdr_cback_data; + xdr_result = (xdrproc_t) xdr_bool; + memset (&argument, 0, sizeof (argument)); + if (!svc_getargs (transp, xdr_argument, (caddr_t) & argument)) + { + svcerr_decode (transp); + return; + } + bool_result = FALSE; + for (i = 0; i < argument.cbproc_receive_1_arg.entries.entries_len; ++i) + { +#define cbproc_entry(a) argument.cbproc_receive_1_arg.entries.entries_val[a] + char name[strlen (cbproc_entry(i)->zo_name) + + strlen (cbproc_entry(i)->zo_domain) + 3]; + char *cp; + + cp = stpcpy (name, cbproc_entry(i)->zo_name); + *cp++ = '.'; + cp = stpcpy (cp, cbproc_entry(i)->zo_domain); + + if ((data->callback) (name, cbproc_entry(i), data->userdata)) + { + bool_result = TRUE; + data->nomore = 1; + data->result = NIS_SUCCESS; + break; + } + } + result = (char *) &bool_result; + } + break; + case CBPROC_FINISH: + xdr_argument = (xdrproc_t) xdr_void; + xdr_result = (xdrproc_t) xdr_void; + memset (&argument, 0, sizeof (argument)); + if (!svc_getargs (transp, xdr_argument, (caddr_t) & argument)) + { + svcerr_decode (transp); + return; + } + data->nomore = 1; + data->result = NIS_SUCCESS; + bool_result = TRUE; /* to make gcc happy, not necessary */ + result = (char *) &bool_result; + break; + case CBPROC_ERROR: + xdr_argument = (xdrproc_t) _xdr_nis_error; + xdr_result = (xdrproc_t) xdr_void; + memset (&argument, 0, sizeof (argument)); + if (!svc_getargs (transp, xdr_argument, (caddr_t) & argument)) + { + svcerr_decode (transp); + return; + } + data->nomore = 1; + data->result = argument.cbproc_error_1_arg; + bool_result = TRUE; /* to make gcc happy, not necessary */ + result = (char *) &bool_result; + break; + default: + svcerr_noproc (transp); + return; + } + if (result != NULL && !svc_sendreply (transp, xdr_result, result)) + svcerr_systemerr (transp); + if (!svc_freeargs (transp, xdr_argument, (caddr_t) & argument)) + { + fputs (_ ("unable to free arguments"), stderr); + exit (1); + } + return; +} + +static nis_error +internal_nis_do_callback (struct dir_binding *bptr, netobj *cookie, + struct nis_cb *cb) +{ + struct timeval TIMEOUT = {25, 0}; + bool_t cb_is_running; + + data = cb; + + for (;;) + { + struct pollfd my_pollfd[svc_max_pollfd]; + int i; + + if (svc_max_pollfd == 0 && svc_pollfd == NULL) + return NIS_CBERROR; + + for (i = 0; i < svc_max_pollfd; ++i) + { + my_pollfd[i].fd = svc_pollfd[i].fd; + my_pollfd[i].events = svc_pollfd[i].events; + my_pollfd[i].revents = 0; + } + + switch (i = TEMP_FAILURE_RETRY (poll (my_pollfd, svc_max_pollfd, + 25*1000))) + { + case -1: + return NIS_CBERROR; + case 0: + /* See if callback 'thread' in the server is still alive. */ + cb_is_running = FALSE; + if (clnt_call (bptr->clnt, NIS_CALLBACK, (xdrproc_t) xdr_netobj, + (caddr_t) cookie, (xdrproc_t) xdr_bool, + (caddr_t) &cb_is_running, TIMEOUT) != RPC_SUCCESS) + cb_is_running = FALSE; + + if (cb_is_running == FALSE) + { + syslog (LOG_ERR, "NIS+: callback timed out"); + return NIS_CBERROR; + } + break; + default: + svc_getreq_poll (my_pollfd, i); + if (data->nomore) + return data->result; + } + } +} + +nis_error +__nis_do_callback (struct dir_binding *bptr, netobj *cookie, + struct nis_cb *cb) +{ + nis_error result; + + __libc_lock_lock (callback_lock); + + result = internal_nis_do_callback (bptr, cookie, cb); + + __libc_lock_unlock (callback_lock); + + return result; +} + +struct nis_cb * +__nis_create_callback (int (*callback) (const_nis_name, const nis_object *, + const void *), + const void *userdata, unsigned int flags) +{ + struct nis_cb *cb; + int sock = RPC_ANYSOCK; + struct sockaddr_in sin; + socklen_t len = sizeof (struct sockaddr_in); + unsigned short port; + int nomsg = 0; + + cb = (struct nis_cb *) calloc (1, + sizeof (struct nis_cb) + sizeof (nis_server)); + if (cb == NULL) + goto failed; + cb->serv = (nis_server *) (cb + 1); + cb->serv->name = strdup (nis_local_principal ()); + if (cb->serv->name == NULL) + goto failed; + cb->serv->ep.ep_val = (endpoint *) calloc (2, sizeof (endpoint)); + if (cb->serv->ep.ep_val == NULL) + goto failed; + cb->serv->ep.ep_len = 1; + cb->serv->ep.ep_val[0].family = strdup ("inet"); + if (cb->serv->ep.ep_val[0].family == NULL) + goto failed; + cb->callback = callback; + cb->userdata = userdata; + + if ((flags & NO_AUTHINFO) || !key_secretkey_is_set ()) + { + cb->serv->key_type = NIS_PK_NONE; + cb->serv->pkey.n_bytes = NULL; + cb->serv->pkey.n_len = 0; + } + else + { +#if 0 + if ((cb->serv->pkey.n_bytes = __nis_getpkey (cb->serv->name)) == NULL) + { + cb->serv->pkey.n_len = 0; + cb->serv->key_type = NIS_PK_NONE; + } + else + { + cb->serv->key_type = NIS_PK_DH; + cb->serv->pkey.n_len = strlen(cb->serv->pkey.n_bytes); + } +#else + cb->serv->pkey.n_len =0; + cb->serv->pkey.n_bytes = NULL; + cb->serv->key_type = NIS_PK_NONE; +#endif + } + + cb->serv->ep.ep_val[0].proto = strdup ((flags & USE_DGRAM) ? "udp" : "tcp"); + if (cb->serv->ep.ep_val[0].proto == NULL) + goto failed; + cb->xprt = ((flags & USE_DGRAM) + ? svcudp_bufcreate (sock, 100, 8192) + : svctcp_create (sock, 100, 8192)); + if (cb->xprt == NULL) + { + nomsg = 1; + goto failed; + } +#if defined(HAVE_TIRPC) + cb->sock = cb->xprt->xp_fd; +#else + cb->sock = cb->xprt->xp_sock; +#endif + if (!svc_register (cb->xprt, CB_PROG, CB_VERS, cb_prog_1, 0)) + { + xprt_unregister (cb->xprt); + svc_destroy (cb->xprt); + xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv); + free (cb); + syslog (LOG_ERR, "NIS+: failed to register callback dispatcher"); + return NULL; + } + + if (getsockname (cb->sock, (struct sockaddr *) &sin, &len) == -1) + { + xprt_unregister (cb->xprt); + svc_destroy (cb->xprt); + xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv); + free (cb); + syslog (LOG_ERR, "NIS+: failed to read local socket info"); + return NULL; + } + port = ntohs (sin.sin_port); + get_myaddress (&sin); + + if (asprintf (&cb->serv->ep.ep_val[0].uaddr, "%s.%d.%d", + inet_ntoa (sin.sin_addr), (port & 0xFF00) >> 8, port & 0x00FF) + < 0) + goto failed; + + return cb; + + failed: + if (cb) + { + if (cb->xprt) + svc_destroy (cb->xprt); + xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv); + free (cb); + } + if (!nomsg) + syslog (LOG_ERR, "NIS+: out of memory allocating callback"); + return NULL; +} + +nis_error +__nis_destroy_callback (struct nis_cb *cb) +{ + xprt_unregister (cb->xprt); + svc_destroy (cb->xprt); + close (cb->sock); + xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv); + free (cb); + + return NIS_SUCCESS; +} diff --git a/src/nisplus/nis_checkpoint.c b/src/nisplus/nis_checkpoint.c new file mode 100644 index 0000000..e634191 --- /dev/null +++ b/src/nisplus/nis_checkpoint.c @@ -0,0 +1,82 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "nis_intern.h" +#include "nis_xdr.h" + + +nis_result * +nis_checkpoint (const_nis_name dirname) +{ + nis_result *res; + + res = calloc (1, sizeof (nis_result)); + if (res == NULL) + return NULL; + + if (dirname != NULL) + { + nis_result *res2; + u_int i; + + res2 = nis_lookup (dirname, EXPAND_NAME); + if (NIS_RES_STATUS (res2) != NIS_SUCCESS) + { + free (res); + return res2; + } + + /* Check if obj is really a diryectory object */ + if (__type_of (NIS_RES_OBJECT (res2)) != NIS_DIRECTORY_OBJ) + { + nis_freeresult (res2); + NIS_RES_STATUS (res) = NIS_INVALIDOBJ; + return res; + } + + for (i = 0; + i < NIS_RES_OBJECT (res2)->DI_data.do_servers.do_servers_len; ++i) + { + cp_result cpres; + + memset (&cpres, '\0', sizeof (cp_result)); + if (__do_niscall2 (&NIS_RES_OBJECT(res2)->DI_data.do_servers.do_servers_val[i], + 1, NIS_CHECKPOINT, (xdrproc_t) _xdr_nis_name, + (caddr_t) &dirname, (xdrproc_t) _xdr_cp_result, + (caddr_t) &cpres, 0, NULL) != NIS_SUCCESS) + NIS_RES_STATUS (res) = NIS_RPCERROR; + else + { + NIS_RES_STATUS (res) = cpres.cp_status; + res->zticks += cpres.cp_zticks; + res->dticks += cpres.cp_dticks; + } + } + nis_freeresult (res2); + } + else + NIS_RES_STATUS (res) = NIS_NOSUCHNAME; + + return res; +} diff --git a/src/nisplus/nis_clone_dir.c b/src/nisplus/nis_clone_dir.c new file mode 100644 index 0000000..67fb462 --- /dev/null +++ b/src/nisplus/nis_clone_dir.c @@ -0,0 +1,76 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include "nis_intern.h" +#include "nis_xdr.h" + +directory_obj * +nis_clone_directory (const directory_obj *src, directory_obj *dest) +{ + char *addr; + unsigned int size; + XDR xdrs; + + if (src == NULL) + return NULL; + + size = xdr_sizeof ((xdrproc_t)_xdr_directory_obj, (char *)src); + if ((addr = calloc(1, size)) == NULL) + return NULL; + + xdrmem_create(&xdrs, addr, size, XDR_ENCODE); + if (!_xdr_directory_obj (&xdrs, (directory_obj *)src)) + { + xdr_destroy (&xdrs); + free (addr); + return NULL; + } + xdr_destroy (&xdrs); + + directory_obj *res; + if (dest == NULL) + { + if ((res = calloc (1, sizeof (directory_obj))) == NULL) + { + free (addr); + return NULL; + } + } + else + res = dest; + + xdrmem_create (&xdrs, addr, size, XDR_DECODE); + if (!_xdr_directory_obj (&xdrs, res)) + { + xdr_destroy (&xdrs); + if (res != dest) + free (res); + free (addr); + return NULL; + } + xdr_destroy (&xdrs); + free (addr); + + return res; +} diff --git a/src/nisplus/nis_clone_obj.c b/src/nisplus/nis_clone_obj.c new file mode 100644 index 0000000..187b92d --- /dev/null +++ b/src/nisplus/nis_clone_obj.c @@ -0,0 +1,70 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include "nis_intern.h" +#include "nis_xdr.h" + + +nis_object * +nis_clone_object (const nis_object *src, nis_object *dest) +{ + char *addr; + unsigned int size; + XDR xdrs; + nis_object *res = NULL; + + if (src == NULL) + return (NULL); + + size = xdr_sizeof ((xdrproc_t)_xdr_nis_object, (char *) src); + if ((addr = calloc (1, size)) == NULL) + return NULL; + + if (dest == NULL) + { + if ((res = calloc (1, sizeof (nis_object))) == NULL) + goto out; + } + else + res = dest; + + xdrmem_create (&xdrs, addr, size, XDR_ENCODE); + if (!_xdr_nis_object (&xdrs, (nis_object *) src)) + goto out2; + xdr_destroy (&xdrs); + xdrmem_create (&xdrs, addr, size, XDR_DECODE); + if (!_xdr_nis_object (&xdrs, res)) + { + out2: + if (dest == NULL) + free (res); + res = NULL; + } + + xdr_destroy (&xdrs); + out: + free (addr); + + return res; +} diff --git a/src/nisplus/nis_clone_res.c b/src/nisplus/nis_clone_res.c new file mode 100644 index 0000000..3f20070 --- /dev/null +++ b/src/nisplus/nis_clone_res.c @@ -0,0 +1,73 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#include +#include +#include + +#include "nis_xdr.h" + +nis_result * +nis_clone_result (const nis_result *src, nis_result *dest) +{ + char *addr; + unsigned int size; + XDR xdrs; + + if (src == NULL) + return (NULL); + + size = xdr_sizeof ((xdrproc_t)_xdr_nis_result, (char *)src); + if ((addr = calloc(1, size)) == NULL) + return NULL; + + xdrmem_create (&xdrs, addr, size, XDR_ENCODE); + if (!_xdr_nis_result (&xdrs, (nis_result *)src)) + { + xdr_destroy (&xdrs); + free (addr); + return NULL; + } + xdr_destroy (&xdrs); + + nis_result *res; + if (dest == NULL) + { + if ((res = calloc (1, sizeof (nis_result))) == NULL) + { + free (addr); + return NULL; + } + } + else + res = dest; + + xdrmem_create (&xdrs, addr, size, XDR_DECODE); + if (!_xdr_nis_result (&xdrs, res)) + { + xdr_destroy (&xdrs); + if (res != dest) + free (res); + free (addr); + return NULL; + } + xdr_destroy (&xdrs); + free (addr); + + return res; +} diff --git a/src/nisplus/nis_creategroup.c b/src/nisplus/nis_creategroup.c new file mode 100644 index 0000000..7eefab9 --- /dev/null +++ b/src/nisplus/nis_creategroup.c @@ -0,0 +1,83 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#include +#include +#include + +nis_error +nis_creategroup (const_nis_name group, unsigned int flags) +{ + if (group != NULL && group[0] != '\0') + { + size_t grouplen = strlen (group); + char buf[grouplen + 50]; + char leafbuf[grouplen + 2]; + char domainbuf[grouplen + 2]; + nis_error status; + nis_result *res; + char *cp, *cp2; + nis_object *obj; + + cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1)); + cp = stpcpy (cp, ".groups_dir"); + cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); + if (cp2 != NULL && cp2[0] != '\0') + { + *cp++ = '.'; + stpcpy (cp, cp2); + } + else + return NIS_BADNAME; + + obj = calloc (1, sizeof (nis_object)); + if (obj == NULL) + return NIS_NOMEMORY; + + obj->zo_oid.ctime = obj->zo_oid.mtime = time (NULL); + obj->zo_name = strdup (leafbuf); + obj->zo_owner = __nis_default_owner (NULL); + obj->zo_group = __nis_default_group (NULL); + obj->zo_domain = strdup (domainbuf); + if (obj->zo_name == NULL || obj->zo_owner == NULL + || obj->zo_group == NULL || obj->zo_domain == NULL) + { + free (obj->zo_group); + free (obj->zo_owner); + free (obj->zo_name); + free (obj); + return NIS_NOMEMORY; + } + obj->zo_access = __nis_default_access (NULL, 0); + obj->zo_ttl = 60 * 60; + obj->zo_data.zo_type = NIS_GROUP_OBJ; + obj->zo_data.objdata_u.gr_data.gr_flags = flags; + obj->zo_data.objdata_u.gr_data.gr_members.gr_members_len = 0; + obj->zo_data.objdata_u.gr_data.gr_members.gr_members_val = NULL; + + res = nis_add (buf, obj); + nis_free_object (obj); + if (res == NULL) + return NIS_NOMEMORY; + status = NIS_RES_STATUS (res); + nis_freeresult (res); + + return status; + } + return NIS_FAIL; +} diff --git a/src/nisplus/nis_defaults.c b/src/nisplus/nis_defaults.c new file mode 100644 index 0000000..74c6f7c --- /dev/null +++ b/src/nisplus/nis_defaults.c @@ -0,0 +1,459 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "nis_intern.h" +#include "nis_xdr.h" + + +#define DEFAULT_TTL 43200 + +/* +** Some functions for parsing the -D param and NIS_DEFAULTS Environ +*/ +static nis_name +searchXYX (char *str, const char *what) +{ + assert (strlen (what) == 6); + assert (strncmp (str, what, 6) == 0); + str += 6; /* Points to the begin of the parameters. */ + + int i = 0; + while (str[i] != '\0' && str[i] != ':') + ++i; + if (i == 0) /* only "=" ? */ + return strdup (""); + + return strndup (str, i); +} + + +static nis_name +searchgroup (char *str) +{ + return searchXYX (str, "group="); +} + + +static nis_name +searchowner (char *str) +{ + return searchXYX (str, "owner="); +} + + +static uint32_t +searchttl (char *str) +{ + char buf[strlen (str) + 1]; + char *cptr, *dptr; + uint32_t time; + int i; + + dptr = strstr (str, "ttl="); + if (dptr == NULL) /* should (could) not happen */ + return DEFAULT_TTL;; + + dptr += 4; /* points to the begin of the new ttl */ + i = 0; + while (dptr[i] != '\0' && dptr[i] != ':') + i++; + if (i == 0) /* only "ttl=" ? */ + return DEFAULT_TTL; + + strncpy (buf, dptr, i); + buf[i] = '\0'; + time = 0; + + dptr = buf; + cptr = strchr (dptr, 'd'); + if (cptr != NULL) + { + *cptr = '\0'; + cptr++; + time += atoi (dptr) * 60 * 60 * 24; + dptr = cptr; + } + + cptr = strchr (dptr, 'h'); + if (cptr != NULL) + { + *cptr = '\0'; + cptr++; + time += atoi (dptr) * 60 * 60; + dptr = cptr; + } + + cptr = strchr (dptr, 'm'); + if (cptr != NULL) + { + *cptr = '\0'; + cptr++; + time += atoi (dptr) * 60; + dptr = cptr; + } + + cptr = strchr (dptr, 's'); + if (cptr != NULL) + *cptr = '\0'; + + time += atoi (dptr); + + return time; +} + +static unsigned int +searchaccess (char *str, unsigned int access) +{ + char buf[strlen (str) + 1]; + char *cptr; + unsigned int result = access; + int i; + int n, o, g, w; + + cptr = strstr (str, "access="); + if (cptr == NULL) + return 0; + + cptr += 7; /* points to the begin of the access string */ + i = 0; + while (cptr[i] != '\0' && cptr[i] != ':') + i++; + if (i == 0) /* only "access=" ? */ + return 0; + + strncpy (buf, cptr, i); + buf[i] = '\0'; + + n = o = g = w = 0; + cptr = buf; + if (*cptr == ',') /* Fix for stupid Solaris scripts */ + ++cptr; + while (*cptr != '\0') + { + switch (*cptr) + { + case 'n': + n = 1; + break; + case 'o': + o = 1; + break; + case 'g': + g = 1; + break; + case 'w': + w = 1; + break; + case 'a': + o = g = w = 1; + break; + case '-': + cptr++; /* Remove "-" from beginning */ + while (*cptr != '\0' && *cptr != ',') + { + switch (*cptr) + { + case 'r': + if (n) + result = result & ~(NIS_READ_ACC << 24); + if (o) + result = result & ~(NIS_READ_ACC << 16); + if (g) + result = result & ~(NIS_READ_ACC << 8); + if (w) + result = result & ~(NIS_READ_ACC); + break; + case 'm': + if (n) + result = result & ~(NIS_MODIFY_ACC << 24); + if (o) + result = result & ~(NIS_MODIFY_ACC << 16); + if (g) + result = result & ~(NIS_MODIFY_ACC << 8); + if (w) + result = result & ~(NIS_MODIFY_ACC); + break; + case 'c': + if (n) + result = result & ~(NIS_CREATE_ACC << 24); + if (o) + result = result & ~(NIS_CREATE_ACC << 16); + if (g) + result = result & ~(NIS_CREATE_ACC << 8); + if (w) + result = result & ~(NIS_CREATE_ACC); + break; + case 'd': + if (n) + result = result & ~(NIS_DESTROY_ACC << 24); + if (o) + result = result & ~(NIS_DESTROY_ACC << 16); + if (g) + result = result & ~(NIS_DESTROY_ACC << 8); + if (w) + result = result & ~(NIS_DESTROY_ACC); + break; + default: + return (~0U); + } + cptr++; + } + n = o = g = w = 0; + break; + case '+': + cptr++; /* Remove "+" from beginning */ + while (*cptr != '\0' && *cptr != ',') + { + switch (*cptr) + { + case 'r': + if (n) + result = result | (NIS_READ_ACC << 24); + if (o) + result = result | (NIS_READ_ACC << 16); + if (g) + result = result | (NIS_READ_ACC << 8); + if (w) + result = result | (NIS_READ_ACC); + break; + case 'm': + if (n) + result = result | (NIS_MODIFY_ACC << 24); + if (o) + result = result | (NIS_MODIFY_ACC << 16); + if (g) + result = result | (NIS_MODIFY_ACC << 8); + if (w) + result = result | (NIS_MODIFY_ACC); + break; + case 'c': + if (n) + result = result | (NIS_CREATE_ACC << 24); + if (o) + result = result | (NIS_CREATE_ACC << 16); + if (g) + result = result | (NIS_CREATE_ACC << 8); + if (w) + result = result | (NIS_CREATE_ACC); + break; + case 'd': + if (n) + result = result | (NIS_DESTROY_ACC << 24); + if (o) + result = result | (NIS_DESTROY_ACC << 16); + if (g) + result = result | (NIS_DESTROY_ACC << 8); + if (w) + result = result | (NIS_DESTROY_ACC); + break; + default: + return (~0U); + } + cptr++; + } + n = o = g = w = 0; + break; + case '=': + cptr++; /* Remove "=" from beginning */ + /* Clear */ + if (n) + result = result & ~((NIS_READ_ACC + NIS_MODIFY_ACC + + NIS_CREATE_ACC + NIS_DESTROY_ACC) << 24); + + if (o) + result = result & ~((NIS_READ_ACC + NIS_MODIFY_ACC + + NIS_CREATE_ACC + NIS_DESTROY_ACC) << 16); + if (g) + result = result & ~((NIS_READ_ACC + NIS_MODIFY_ACC + + NIS_CREATE_ACC + NIS_DESTROY_ACC) << 8); + if (w) + result = result & ~(NIS_READ_ACC + NIS_MODIFY_ACC + + NIS_CREATE_ACC + NIS_DESTROY_ACC); + while (*cptr != '\0' && *cptr != ',') + { + switch (*cptr) + { + case 'r': + if (n) + result = result | (NIS_READ_ACC << 24); + if (o) + result = result | (NIS_READ_ACC << 16); + if (g) + result = result | (NIS_READ_ACC << 8); + if (w) + result = result | (NIS_READ_ACC); + break; + case 'm': + if (n) + result = result | (NIS_MODIFY_ACC << 24); + if (o) + result = result | (NIS_MODIFY_ACC << 16); + if (g) + result = result | (NIS_MODIFY_ACC << 8); + if (w) + result = result | (NIS_MODIFY_ACC); + break; + case 'c': + if (n) + result = result | (NIS_CREATE_ACC << 24); + if (o) + result = result | (NIS_CREATE_ACC << 16); + if (g) + result = result | (NIS_CREATE_ACC << 8); + if (w) + result = result | (NIS_CREATE_ACC); + break; + case 'd': + if (n) + result = result | (NIS_DESTROY_ACC << 24); + if (o) + result = result | (NIS_DESTROY_ACC << 16); + if (g) + result = result | (NIS_DESTROY_ACC << 8); + if (w) + result = result | (NIS_DESTROY_ACC); + break; + default: + return result = (~0U); + } + cptr++; + } + n = o = g = w = 0; + break; + default: + return result = (~0U); + } + if (*cptr != '\0') + cptr++; + } + + return result; +} + + +nis_name +__nis_default_owner (char *defaults) +{ + char *default_owner = NULL; + + char *cptr = defaults; + if (cptr == NULL) + cptr = getenv ("NIS_DEFAULTS"); + + if (cptr != NULL) + { + char *dptr = strstr (cptr, "owner="); + if (dptr != NULL) + { + char *p = searchowner (dptr); + if (p == NULL) + return NULL; + default_owner = strdupa (p); + free (p); + } + } + + return strdup (default_owner ?: nis_local_principal ()); +} + + +nis_name +__nis_default_group (char *defaults) +{ + char *default_group = NULL; + + char *cptr = defaults; + if (cptr == NULL) + cptr = getenv ("NIS_DEFAULTS"); + + if (cptr != NULL) + { + char *dptr = strstr (cptr, "group="); + if (dptr != NULL) + { + char *p = searchgroup (dptr); + if (p == NULL) + return NULL; + default_group = strdupa (p); + free (p); + } + } + + return strdup (default_group ?: nis_local_group ()); +} + + +uint32_t +__nis_default_ttl (char *defaults) +{ + char *cptr, *dptr; + + if (defaults != NULL) + { + dptr = strstr (defaults, "ttl="); + if (dptr != NULL) + return searchttl (defaults); + } + + cptr = getenv ("NIS_DEFAULTS"); + if (cptr == NULL) + return DEFAULT_TTL; + + dptr = strstr (cptr, "ttl="); + if (dptr == NULL) + return DEFAULT_TTL; + + return searchttl (cptr); +} + +/* Default access rights are ----rmcdr---r---, but we could change + this with the NIS_DEFAULTS variable. */ +unsigned int +__nis_default_access (char *param, unsigned int defaults) +{ + unsigned int result; + char *cptr; + + if (defaults == 0) + result = 0 | OWNER_DEFAULT | GROUP_DEFAULT | WORLD_DEFAULT; + else + result = defaults; + + if (param != NULL && strstr (param, "access=") != NULL) + result = searchaccess (param, result); + else + { + cptr = getenv ("NIS_DEFAULTS"); + if (cptr != NULL && strstr (cptr, "access=") != NULL) + result = searchaccess (cptr, result); + } + + return result; +} diff --git a/src/nisplus/nis_destroygroup.c b/src/nisplus/nis_destroygroup.c new file mode 100644 index 0000000..e0c4f13 --- /dev/null +++ b/src/nisplus/nis_destroygroup.c @@ -0,0 +1,55 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +nis_error +nis_destroygroup (const_nis_name group) +{ + if (group != NULL && group[0] != '\0') + { + size_t grouplen = strlen (group); + char buf[grouplen + 50]; + char leafbuf[grouplen + 3]; + char domainbuf[grouplen + 3]; + nis_error status; + nis_result *res; + char *cp, *cp2; + + cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1)); + cp = stpcpy (cp, ".groups_dir"); + cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); + if (cp2 != NULL && cp2[0] != '\0') + { + *cp++ = '.'; + stpcpy (cp, cp2); + } + res = nis_remove (buf, NULL); + status = NIS_RES_STATUS (res); + nis_freeresult (res); + return status; + } + else + return NIS_FAIL; + +} diff --git a/src/nisplus/nis_domain_of.c b/src/nisplus/nis_domain_of.c new file mode 100644 index 0000000..d48bd6b --- /dev/null +++ b/src/nisplus/nis_domain_of.c @@ -0,0 +1,45 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "nis_intern.h" + +nis_name +nis_domain_of (const_nis_name name) +{ + static char result[NIS_MAXNAMELEN + 1]; + + return nis_domain_of_r (name, result, NIS_MAXNAMELEN); +} + +const_nis_name +__nis_domain_of (const_nis_name name) +{ + const_nis_name cptr = strchr (name, '.'); + + if (cptr == NULL) + return ""; + + if (*++cptr == '\0') + return "."; + + return cptr; +} diff --git a/src/nisplus/nis_domain_of_r.c b/src/nisplus/nis_domain_of_r.c new file mode 100644 index 0000000..a5ac9f3 --- /dev/null +++ b/src/nisplus/nis_domain_of_r.c @@ -0,0 +1,66 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "nis_intern.h" +#include "nis_xdr.h" + +nis_name +nis_domain_of_r (const_nis_name name, char *buffer, size_t buflen) +{ + char *cptr; + size_t cptr_len; + + if (buffer == NULL) + { + erange: + errno = ERANGE; + return NULL; + } + + buffer[0] = '\0'; + + cptr = strchr (name, '.'); + + if (cptr == NULL) + return buffer; + + ++cptr; + cptr_len = strlen (cptr); + + if (cptr_len == 0) + { + if (buflen < 2) + goto erange; + return strcpy (buffer, "."); + } + + if (cptr_len >= buflen) + { + errno = ERANGE; + return NULL; + } + + return memcpy (buffer, cptr, cptr_len + 1); +} diff --git a/src/nisplus/nis_error.c b/src/nisplus/nis_error.c new file mode 100644 index 0000000..b5214bc --- /dev/null +++ b/src/nisplus/nis_error.c @@ -0,0 +1,126 @@ +/* Copyright (C) 2015 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#ifndef _ +#define _(String) gettext (String) +#endif + +#ifndef N_ +#define N_(String) String +#endif + +static char *msgstr[] = { + N_("Success"), + N_("Probable success"), + N_("Not found"), + N_("Probably not found"), + N_("Cache expired"), + N_("NIS+ servers unreachable"), + N_("Unknown object"), + N_("Server busy, try again"), + N_("Generic system error"), + N_("First/next chain broken"), + N_("Permission denied"), + N_("Not owner"), + N_("Name not served by this server"), + N_("Server out of memory"), + N_("Object with same name exists"), + N_("Not master server for this domain"), + N_("Invalid object for operation"), + N_("Malformed name, or illegal name"), + N_("Unable to create callback"), + N_("Results sent to callback proc"), + N_("Not found, no such name"), + N_("Name/entry isn't unique"), + N_("Modification failed"), + N_("Database for table does not exist"), + N_("Entry/table type mismatch"), + N_("Link points to illegal name"), + N_("Partial success"), + N_("Too many attributes"), + N_("Error in RPC subsystem"), + N_("Missing or malformed attribute"), + N_("Named object is not searchable"), + N_("Error while talking to callback proc"), + N_("Non NIS+ namespace encountered"), + N_("Illegal object type for operation"), + N_("Passed object is not the same object on server"), + N_("Modify operation failed"), + N_("Query illegal for named table"), + N_("Attempt to remove a non-empty table"), + N_("Error in accessing NIS+ cold start file. Is NIS+ installed?"), + N_("Full resync required for directory"), + N_("NIS+ operation failed"), + N_("NIS+ service is unavailable or not installed"), + N_("Yes, 42 is the meaning of life"), + N_("Unable to authenticate NIS+ server"), + N_("Unable to authenticate NIS+ client"), + N_("No file space on server"), + N_("Unable to create process on server"), + N_("Master server busy, full dump rescheduled.")}; + +const char * +nis_sperrno (const nis_error status) +{ + if (status >= sizeof (msgstr) / sizeof (msgstr[0])) + return "???"; + else + return _(msgstr[status]); +} + + +void +nis_perror (const nis_error status, const char *label) +{ + fprintf (stderr, "%s: %s\n", label, nis_sperrno (status)); +} + +void +nis_lerror (const nis_error status, const char *label) +{ + syslog (LOG_ERR, "%s: %s", label, nis_sperrno (status)); +} + +char * +nis_sperror_r (const nis_error status, const char *label, + char *buffer, size_t buflen) +{ + if (snprintf (buffer, buflen, "%s: %s", label, nis_sperrno (status)) + >= (int)buflen) + { + errno=ERANGE; + return NULL; + } + + return buffer; +} + +char * +nis_sperror (const nis_error status, const char *label) +{ + static char buffer[NIS_MAXNAMELEN + 1]; + + return nis_sperror_r (status, label, buffer, sizeof (buffer)); +} diff --git a/src/nisplus/nis_file.c b/src/nisplus/nis_file.c new file mode 100644 index 0000000..03833d7 --- /dev/null +++ b/src/nisplus/nis_file.c @@ -0,0 +1,107 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "nis_intern.h" +#include "nis_xdr.h" + +typedef bool_t (*iofct_t) (XDR *, void *); +typedef void (*freefct_t) (void *); + + +static void * +read_nis_obj (const char *name, iofct_t readfct, freefct_t freefct, + size_t objsize) +{ + FILE *in = fopen (name, "rce"); + if (in == NULL) + return NULL; + + void *obj = calloc (1, objsize); + + if (obj != NULL) + { + XDR xdrs; + xdrstdio_create (&xdrs, in, XDR_DECODE); + bool_t status = readfct (&xdrs, obj); + xdr_destroy (&xdrs); + + if (!status) + { + freefct (obj); + obj = NULL; + } + } + + fclose (in); + + return obj; +} + +static bool_t +write_nis_obj (const char *name, const void *obj, iofct_t writefct) +{ + FILE *out = fopen (name, "wce"); + if (out == NULL) + return FALSE; + + XDR xdrs; + xdrstdio_create (&xdrs, out, XDR_ENCODE); + bool_t status = writefct (&xdrs, (void *) obj); + xdr_destroy (&xdrs); + fclose (out); + + return status; +} + + +static const char cold_start_file[] = "/var/nis/NIS_COLD_START"; + +directory_obj * +readColdStartFile (void) +{ + return read_nis_obj (cold_start_file, (iofct_t) _xdr_directory_obj, + (freefct_t) nis_free_directory, sizeof (directory_obj)); +} + +bool_t +writeColdStartFile (const directory_obj *obj) +{ + return write_nis_obj (cold_start_file, obj, (iofct_t) _xdr_directory_obj); +} + +nis_object * +nis_read_obj (const char *name) +{ + return read_nis_obj (name, (iofct_t) _xdr_nis_object, + (freefct_t) nis_free_object, sizeof (nis_object)); +} + +bool_t +nis_write_obj (const char *name, const nis_object *obj) +{ + return write_nis_obj (name, obj, (iofct_t) _xdr_nis_object); +} diff --git a/src/nisplus/nis_findserv.c b/src/nisplus/nis_findserv.c new file mode 100644 index 0000000..f60ca9c --- /dev/null +++ b/src/nisplus/nis_findserv.c @@ -0,0 +1,229 @@ +/* Copyright (C) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +// #include +// #include + +#include "nis_intern.h" + +/* Private data kept per client handle, from sunrpc/clnt_udp.c */ +struct cu_data + { + int cu_sock; + bool_t cu_closeit; + struct sockaddr_in cu_raddr; + int cu_rlen; + struct timeval cu_wait; + struct timeval cu_total; + struct rpc_err cu_error; + XDR cu_outxdrs; + u_int cu_xdrpos; + u_int cu_sendsz; + char *cu_outbuf; + u_int cu_recvsz; + char cu_inbuf[1]; + }; + + +/* + * Find the mapped port for program,version. + * Calls the pmap service remotely to do the lookup. + * Returns 0 if no map exists. + */ +u_short +__pmap_getnisport (struct sockaddr_in *address, u_long program, + u_long version, u_int protocol) +{ +#if 1 + /* XXX this is not IPv6 ready, and timeout too long */ + return pmap_getport (address, program, version, protocol); +#else + return __libc_rpc_getport (address, program, version, protocol, 1, 1); +#endif /* HAVE_TIRPC */ + +} + +/* This is now the public function, which should find the fastest server */ + +struct findserv_req +{ + struct sockaddr_in sin; + u_int32_t xid; + u_int server_nr; + u_int server_ep; +}; + + +static long int +__nis_findfastest_with_timeout (dir_binding *bind, + const struct timeval *timeout) +{ + static const struct timeval TIMEOUT00 = { 0, 0 }; + struct findserv_req *pings; + struct sockaddr_in sin, saved_sin; + int found = -1; + u_int32_t xid_seed; + int sock, dontblock = 1; + CLIENT *clnt; + u_long i, j, pings_count, pings_max, fastest = -1; + struct cu_data *cu; + + pings_max = bind->server_len * 2; /* Reserve a little bit more memory + for multihomed hosts */ + pings_count = 0; + pings = malloc (sizeof (struct findserv_req) * pings_max); + xid_seed = (u_int32_t) (time (NULL) ^ getpid ()); + + if (pings == NULL) + return -1; + + memset (&sin, '\0', sizeof (sin)); + sin.sin_family = AF_INET; + for (i = 0; i < bind->server_len; i++) + for (j = 0; j < bind->server_val[i].ep.ep_len; ++j) + if (strcmp (bind->server_val[i].ep.ep_val[j].family, "inet") == 0) + if ((bind->server_val[i].ep.ep_val[j].proto == NULL) || + (bind->server_val[i].ep.ep_val[j].proto[0] == '-') || + (bind->server_val[i].ep.ep_val[j].proto[0] == '\0')) + { + sin.sin_addr.s_addr = + inetstr2int (bind->server_val[i].ep.ep_val[j].uaddr); + if (sin.sin_addr.s_addr == 0) + continue; + sin.sin_port = htons (__pmap_getnisport (&sin, NIS_PROG, + NIS_VERSION, + IPPROTO_UDP)); + if (sin.sin_port == 0) + continue; + + if (pings_count >= pings_max) + { + struct findserv_req *new_pings; + + pings_max += 10; + new_pings = realloc (pings, sizeof (struct findserv_req) * + pings_max); + if (new_pings == NULL) + { + free (pings); + return -1; + } + pings = new_pings; + } + memcpy ((char *) &pings[pings_count].sin, (char *) &sin, + sizeof (sin)); + memcpy ((char *)&saved_sin, (char *)&sin, sizeof(sin)); + pings[pings_count].xid = xid_seed + pings_count; + pings[pings_count].server_nr = i; + pings[pings_count].server_ep = j; + ++pings_count; + } + + /* Make sure at least one server was assigned */ + if (pings_count == 0) + { + free (pings); + return -1; + } + + /* Create RPC handle */ + sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP); + clnt = clntudp_create (&saved_sin, NIS_PROG, NIS_VERSION, *timeout, &sock); + if (clnt == NULL) + { + close (sock); + free (pings); + return -1; + } + auth_destroy (clnt->cl_auth); + clnt->cl_auth = authunix_create_default (); + cu = (struct cu_data *) clnt->cl_private; + ioctl (sock, FIONBIO, &dontblock); + /* Send to all servers the NULLPROC */ + for (i = 0; i < pings_count; ++i) + { + /* clntudp_call() will increment, subtract one */ + *((u_int32_t *) (cu->cu_outbuf)) = pings[i].xid - 1; + memcpy ((char *) &cu->cu_raddr, (char *) &pings[i].sin, + sizeof (struct sockaddr_in)); + /* Transmit to NULLPROC, return immediately. */ + clnt_call (clnt, NULLPROC, + (xdrproc_t) xdr_void, (caddr_t) 0, + (xdrproc_t) xdr_void, (caddr_t) 0, TIMEOUT00); + } + + while (found == -1) { + /* Receive reply from NULLPROC asynchronously. Note null inproc. */ + int rc = clnt_call (clnt, NULLPROC, + (xdrproc_t) NULL, (caddr_t) 0, + (xdrproc_t) xdr_void, (caddr_t) 0, + *timeout); + if (RPC_SUCCESS == rc) { + u_int32_t val; + memcpy (&val, cu->cu_inbuf, sizeof (u_int32_t)); + fastest = val - xid_seed; + if (fastest < pings_count) { + bind->server_used = pings[fastest].server_nr; + bind->current_ep = pings[fastest].server_ep; + found = 1; + } + } else { + /* clnt_perror(clnt, "__nis_findfastest"); */ + break; + } + } + + + auth_destroy (clnt->cl_auth); + clnt_destroy (clnt); + close (sock); + + free (pings); + + return found; +} + + +long int +__nis_findfastest (dir_binding *bind) +{ + struct timeval timeout = { __NIS_PING_TIMEOUT_START, 0 }; + long int found = -1; + long int retry = __NIS_PING_RETRY + 1; + + while (retry--) + { + found = __nis_findfastest_with_timeout (bind, &timeout); + if (found != -1) + break; + timeout.tv_sec += __NIS_PING_TIMEOUT_INCREMENT; + } + + return found; +} diff --git a/src/nisplus/nis_free.c b/src/nisplus/nis_free.c new file mode 100644 index 0000000..bfb678f --- /dev/null +++ b/src/nisplus/nis_free.c @@ -0,0 +1,78 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "nis_intern.h" +#include "nis_xdr.h" + +void +__free_fdresult (fd_result *res) +{ + if (res != NULL) + { + xdr_free ((xdrproc_t)_xdr_fd_result, (char *)res); + free (res); + } +} + + +void +nis_free_request (ib_request *ibreq) +{ + if (ibreq != NULL) + { + xdr_free ((xdrproc_t)_xdr_ib_request, (char *)ibreq); + free (ibreq); + } +} + + +void +nis_free_directory (directory_obj *obj) +{ + if (obj != NULL) + { + xdr_free ((xdrproc_t)_xdr_directory_obj, (char *)obj); + free (obj); + } +} + + +void +nis_free_object (nis_object *obj) +{ + if (obj != NULL) + { + xdr_free ((xdrproc_t)_xdr_nis_object, (char *)obj); + free (obj); + } +} + + +void +nis_freeresult (nis_result *res) +{ + if (res != NULL) + { + xdr_free ((xdrproc_t)_xdr_nis_result, (char *)res); + free (res); + } +} diff --git a/src/nisplus/nis_getservlist.c b/src/nisplus/nis_getservlist.c new file mode 100644 index 0000000..d6205a1 --- /dev/null +++ b/src/nisplus/nis_getservlist.c @@ -0,0 +1,170 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "nis_intern.h" +#include "nis_xdr.h" + +nis_server ** +nis_getservlist (const_nis_name dir) +{ + nis_result *res; + nis_server **serv; + + res = nis_lookup (dir, FOLLOW_LINKS); + + if (res != NULL && NIS_RES_STATUS (res) == NIS_SUCCESS) + { + unsigned long i; + nis_server *server; + + serv = + malloc (sizeof (nis_server *) * + (NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len + 1)); + if (serv == NULL) + { + nis_freeresult (res); + return NULL; + } + + for (i = 0; i < NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len; + ++i) + { + server = + &NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_val[i]; + serv[i] = calloc (1, sizeof (nis_server)); + if (serv[i] == NULL) + { + free_all: + while (i-- > 0) + { + free (serv[i]->pkey.n_bytes); + if (serv[i]->ep.ep_val != NULL) + { + unsigned long int j; + for (j = 0; j < serv[i]->ep.ep_len; ++j) + { + free (serv[i]->ep.ep_val[j].proto); + free (serv[i]->ep.ep_val[j].family); + free (serv[i]->ep.ep_val[j].uaddr); + } + free (serv[i]->ep.ep_val); + } + free (serv[i]->name); + free (serv[i]); + } + + free (serv); + + nis_freeresult (res); + + return NULL; + } + + if (server->name != NULL) + { + serv[i]->name = strdup (server->name); + if (serv[i]->name == NULL) + { + ++i; + goto free_all; + } + } + + serv[i]->ep.ep_len = server->ep.ep_len; + if (serv[i]->ep.ep_len > 0) + { + unsigned long int j; + + serv[i]->ep.ep_val = + malloc (server->ep.ep_len * sizeof (endpoint)); + if (serv[i]->ep.ep_val == NULL) + { + ++i; + goto free_all; + } + + for (j = 0; j < serv[i]->ep.ep_len; ++j) + { + if (server->ep.ep_val[j].uaddr) + serv[i]->ep.ep_val[j].uaddr = + strdup (server->ep.ep_val[j].uaddr); + else + serv[i]->ep.ep_val[j].uaddr = NULL; + if (server->ep.ep_val[j].family) + serv[i]->ep.ep_val[j].family = + strdup (server->ep.ep_val[j].family); + else + serv[i]->ep.ep_val[j].family = NULL; + if (server->ep.ep_val[j].proto) + serv[i]->ep.ep_val[j].proto = + strdup (server->ep.ep_val[j].proto); + else + serv[i]->ep.ep_val[j].proto = NULL; + } + } + + serv[i]->key_type = server->key_type; + serv[i]->pkey.n_len = server->pkey.n_len; + if (server->pkey.n_len > 0) + { + serv[i]->pkey.n_bytes = malloc (server->pkey.n_len); + if (serv[i]->pkey.n_bytes == NULL) + { + ++i; + goto free_all; + } + memcpy (serv[i]->pkey.n_bytes, server->pkey.n_bytes, + server->pkey.n_len); + } + } + serv[i] = NULL; + } + else + { + serv = malloc (sizeof (nis_server *)); + if (serv != NULL) + serv[0] = NULL; + } + + nis_freeresult (res); + + return serv; +} + +void +nis_freeservlist (nis_server **serv) +{ + int i; + + if (serv == NULL) + return; + + i = 0; + while (serv[i] != NULL) + { + xdr_free ((xdrproc_t)_xdr_nis_server, (char *)serv[i]); + free (serv[i]); + ++i; + } + free (serv); +} diff --git a/src/nisplus/nis_hash.c b/src/nisplus/nis_hash.c new file mode 100644 index 0000000..c1792c2 --- /dev/null +++ b/src/nisplus/nis_hash.c @@ -0,0 +1,76 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#include +#include + +/* This is from libc/db/hash/hash_func.c, hash3 is static there */ +/* + * This is INCREDIBLY ugly, but fast. We break the string up into 8 byte + * units. On the first time through the loop we get the "leftover bytes" + * (strlen % 8). On every other iteration, we perform 8 HASHC's so we handle + * all 8 bytes. Essentially, this saves us 7 cmp & branch instructions. If + * this routine is heavily used enough, it's worth the ugly coding. + * + * OZ's original sdbm hash + */ +uint32_t +__nis_hash (const void *keyarg, size_t len) +{ + const u_char *key; + size_t loop; + uint32_t h; + +#define HASHC h = *key++ + 65599 * h + + h = 0; + key = keyarg; + if (len > 0) + { + loop = (len + 8 - 1) >> 3; + switch (len & (8 - 1)) + { + case 0: + do { + HASHC; + /* FALLTHROUGH */ + case 7: + HASHC; + /* FALLTHROUGH */ + case 6: + HASHC; + /* FALLTHROUGH */ + case 5: + HASHC; + /* FALLTHROUGH */ + case 4: + HASHC; + /* FALLTHROUGH */ + case 3: + HASHC; + /* FALLTHROUGH */ + case 2: + HASHC; + /* FALLTHROUGH */ + case 1: + HASHC; + } while (--loop); + } + } + return h; +} diff --git a/src/nisplus/nis_intern.h b/src/nisplus/nis_intern.h new file mode 100644 index 0000000..8f29676 --- /dev/null +++ b/src/nisplus/nis_intern.h @@ -0,0 +1,89 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifndef __NIS_INTERN_H +#define __NIS_INTERN_H + +#define NIS_INTERNAL +#include + +/* Configurable parameters for pinging NIS servers: */ + +/* Number of retries. */ +#ifndef __NIS_PING_RETRY +# define __NIS_PING_RETRY 2 +#endif +/* Initial timeout in seconds. */ +#ifndef __NIS_PING_TIMEOUT_START +# define __NIS_PING_TIMEOUT_START 3 +#endif +/* Timeout increment for retries in seconds. */ +#ifndef __NIS_PING_TIMEOUT_INCREMENT +# define __NIS_PING_TIMEOUT_INCREMENT 3 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct nis_cb + { + nis_server *serv; + SVCXPRT *xprt; + int sock; + int nomore; + nis_error result; + int (*callback) (const_nis_name, const nis_object *, const void *); + const void *userdata; + }; +typedef struct nis_cb nis_cb; + +extern unsigned long int inetstr2int (const char *str); +extern long int __nis_findfastest (dir_binding *bind); +extern nis_error __prepare_niscall (const_nis_name name, directory_obj **dirp, + dir_binding *bptrp, unsigned int flags); +extern nis_error __do_niscall2 (const nis_server *serv, u_int serv_len, + u_long prog, xdrproc_t xargs, caddr_t req, + xdrproc_t xres, caddr_t resp, + unsigned int flags, nis_cb *cb); +extern nis_error __do_niscall (const_nis_name name, u_long prog, + xdrproc_t xargs, caddr_t req, + xdrproc_t xres, caddr_t resp, + unsigned int flags, nis_cb *cb); +extern nis_error __do_niscall3 (dir_binding *dbp, u_long prog, + xdrproc_t xargs, caddr_t req, + xdrproc_t xres, caddr_t resp, + unsigned int flags, nis_cb *cb); + +extern u_short __pmap_getnisport (struct sockaddr_in *address, u_long program, + u_long version, u_int protocol); +extern const_nis_name __nis_domain_of (const_nis_name); + +/* NIS+ callback */ +extern nis_error __nis_do_callback (struct dir_binding *bptr, + netobj *cookie, struct nis_cb *cb); +extern struct nis_cb *__nis_create_callback + (int (*callback)(const_nis_name, const nis_object *, const void *), + const void *userdata, unsigned int flags); +extern nis_error __nis_destroy_callback (struct nis_cb *cb); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/nisplus/nis_ismember.c b/src/nisplus/nis_ismember.c new file mode 100644 index 0000000..d142a16 --- /dev/null +++ b/src/nisplus/nis_ismember.c @@ -0,0 +1,152 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +/* internal_nis_ismember () + return codes: -1 principal is in -group + 0 principal isn't in any group + 1 pirncipal is in group */ +static int +internal_ismember (const_nis_name principal, const_nis_name group) +{ + size_t grouplen = strlen (group); + char buf[grouplen + 50]; + char leafbuf[grouplen + 2]; + char domainbuf[grouplen + 2]; + nis_result *res; + char *cp, *cp2; + u_int i; + + cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1)); + cp = stpcpy (cp, ".groups_dir"); + cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); + if (cp2 != NULL && cp2[0] != '\0') + { + *cp++ = '.'; + strcpy (cp, cp2); + } + + res = nis_lookup (buf, EXPAND_NAME|FOLLOW_LINKS); + if (res == NULL || NIS_RES_STATUS (res) != NIS_SUCCESS) + { + nis_freeresult (res); + return 0; + } + + if ((NIS_RES_NUMOBJ (res) != 1) || + (__type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ)) + { + nis_freeresult (res); + return 0; + } + + /* We search twice in the list, at first, if we have the name + with a "-", then if without. "-member" has priority */ + for (i = 0; i < NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len; ++i) + { + cp = NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[i]; + if (cp[0] == '-') + { + if (strcmp (&cp[1], principal) == 0) + { + nis_freeresult (res); + return -1; + } + if (cp[1] == '@') + switch (internal_ismember (principal, &cp[2])) + { + case -1: + nis_freeresult (res); + return -1; + case 1: + nis_freeresult (res); + return 1; + default: + break; + } + else + if (cp[1] == '*') + { + char buf1[strlen (principal) + 2]; + char buf2[strlen (cp) + 2]; + + if (strcmp (nis_domain_of_r (principal, buf1, sizeof buf1), + nis_domain_of_r (cp, buf2, sizeof buf2)) == 0) + { + nis_freeresult (res); + return -1; + } + } + } + } + + for (i = 0; i < NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len; ++i) + { + cp = NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[i]; + if (cp[0] != '-') + { + if (strcmp (cp, principal) == 0) + { + nis_freeresult (res); + return 1; + } + if (cp[0] == '@') + switch (internal_ismember (principal, &cp[1])) + { + case -1: + nis_freeresult (res); + return -1; + case 1: + nis_freeresult (res); + return 1; + default: + break; + } + else + if (cp[0] == '*') + { + char buf1[strlen (principal) + 2]; + char buf2[strlen (cp) + 2]; + + if (strcmp (nis_domain_of_r (principal, buf1, sizeof buf1), + nis_domain_of_r (cp, buf2, sizeof buf2)) == 0) + { + nis_freeresult (res); + return 1; + } + } + } + } + nis_freeresult (res); + return 0; +} + +bool_t +nis_ismember (const_nis_name principal, const_nis_name group) +{ + if (group != NULL && group[0] != '\0' && principal != NULL) + return internal_ismember (principal, group) == 1 ? TRUE : FALSE; + else + return FALSE; +} diff --git a/src/nisplus/nis_local_names.c b/src/nisplus/nis_local_names.c new file mode 100644 index 0000000..c3a5d71 --- /dev/null +++ b/src/nisplus/nis_local_names.c @@ -0,0 +1,185 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include "nis_intern.h" + +#ifndef _ +#define _(String) gettext (String) +#endif + +nis_name +nis_local_group (void) +{ + static char __nisgroup[NIS_MAXNAMELEN + 1]; + + char *cptr; + if (__nisgroup[0] == '\0' + && (cptr = getenv ("NIS_GROUP")) != NULL + && strlen (cptr) < NIS_MAXNAMELEN) + { + char *cp = stpcpy (__nisgroup, cptr); + + if (cp[-1] != '.') + { + cptr = nis_local_directory (); + if ((cp - __nisgroup) + strlen (cptr) + 1 < NIS_MAXNAMELEN) + { + *cp++ = '.'; + strcpy (cp, cptr); + } + else + __nisgroup[0] = '\0'; + } + } + + return __nisgroup; +} + + +nis_name +nis_local_directory (void) +{ + static char __nisdomainname[NIS_MAXNAMELEN + 1]; + + if (__nisdomainname[0] == '\0') + { + if (getdomainname (__nisdomainname, NIS_MAXNAMELEN) < 0) + __nisdomainname[0] = '\0'; + else + { + char *cp = (char *)__nisdomainname + strlen (__nisdomainname); + + /* Missing trailing dot? */ + if (cp[-1] != '.') + { + *cp++ = '.'; + *cp = '\0'; + } + } + } + + return __nisdomainname; +} + + +nis_name +nis_local_principal (void) +{ + static char __principal[NIS_MAXNAMELEN + 1]; + + if (__principal[0] == '\0') + { + char buf[NIS_MAXNAMELEN + 1]; + nis_result *res; + uid_t uid = geteuid (); + + if (uid != 0) + { + int len = snprintf (buf, NIS_MAXNAMELEN - 1, + "[auth_name=%d,auth_type=LOCAL],cred.org_dir.%s", + uid, nis_local_directory ()); + + if (len >= NIS_MAXNAMELEN - 1) + nobody: + /* XXX The buffer is too small. Can this happen??? */ + return strcpy (__principal, "nobody"); + + if (buf[len - 1] != '.') + { + buf[len++] = '.'; + buf[len] = '\0'; + } + + res = nis_list (buf, USE_DGRAM + NO_AUTHINFO + FOLLOW_LINKS + + FOLLOW_PATH, NULL, NULL); + + if (res == NULL) + goto nobody; + + if (NIS_RES_STATUS (res) == NIS_SUCCESS) + { + if (res->objects.objects_len > 1) + { + /* More than one principal with same uid? something + wrong with cred table. Should be unique. Warn user + and continue. */ + printf (_("\ +LOCAL entry for UID %d in directory %s not unique\n"), + uid, nis_local_directory ()); + } + strcpy (__principal, ENTRY_VAL (res->objects.objects_val, 0)); + nis_freeresult (res); + return __principal; + } + else + { + nis_freeresult (res); + goto nobody; + } + } + else + return strcpy (__principal, nis_local_host ()); + + /* Should be never reached */ + goto nobody; + } + return __principal; +} + + +nis_name +nis_local_host (void) +{ + static char __nishostname[NIS_MAXNAMELEN + 1]; + + if (__nishostname[0] == '\0') + { + if (gethostname (__nishostname, NIS_MAXNAMELEN) < 0) + __nishostname[0] = '\0'; + else + { + char *cp = (char *)__nishostname + strlen (__nishostname); + int len = cp - __nishostname; + + /* Hostname already fully qualified? */ + if (cp[-1] == '.') + return __nishostname; + + if (len + strlen (nis_local_directory ()) + 1 > NIS_MAXNAMELEN) + { + __nishostname[0] = '\0'; + return __nishostname; + } + + *cp++ = '.'; + strncpy (cp, nis_local_directory (), NIS_MAXNAMELEN - len -1); + __nishostname[NIS_MAXNAMELEN] = '\0'; + } + } + + return __nishostname; +} diff --git a/src/nisplus/nis_lookup.c b/src/nisplus/nis_lookup.c new file mode 100644 index 0000000..b15f084 --- /dev/null +++ b/src/nisplus/nis_lookup.c @@ -0,0 +1,219 @@ +/* Copyright (C) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "nis_intern.h" +#include "nis_xdr.h" + + +nis_result * +nis_lookup (const_nis_name name, const unsigned int flags) +{ + nis_result *res = calloc (1, sizeof (nis_result)); + struct ns_request req; + nis_name *names; + nis_error status; + int link_first_try = 0; + int count_links = 0; /* We will follow only 16 links in the deep */ + int done = 0; + int name_nr = 0; + nis_name namebuf[2] = {NULL, NULL}; + + if (res == NULL) + return NULL; + + if ((flags & EXPAND_NAME) && (name[strlen (name) - 1] != '.')) + { + names = nis_getnames (name); + if (names == NULL) + { + NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE; + return res; + } + } + else + { + names = namebuf; + names[0] = (nis_name)name; + } + + req.ns_name = names[0]; + while (!done) + { + dir_binding bptr; + directory_obj *dir = NULL; + req.ns_object.ns_object_len = 0; + req.ns_object.ns_object_val = NULL; + + status = __prepare_niscall (req.ns_name, &dir, &bptr, flags); + if (status != NIS_SUCCESS) + { + NIS_RES_STATUS (res) = status; + goto out; + } + + do + { + static const struct timeval RPCTIMEOUT = {10, 0}; + enum clnt_stat result; + + again: + result = clnt_call (bptr.clnt, NIS_LOOKUP, + (xdrproc_t) _xdr_ns_request, + (caddr_t) &req, (xdrproc_t) _xdr_nis_result, + (caddr_t) res, RPCTIMEOUT); + + if (result != RPC_SUCCESS) + status = NIS_RPCERROR; + else + { + status = NIS_SUCCESS; + + if (NIS_RES_STATUS (res) == NIS_SUCCESS) + { + if (__type_of (NIS_RES_OBJECT (res)) == NIS_LINK_OBJ + && (flags & FOLLOW_LINKS)) /* We are following links */ + { + /* if we hit the link limit, bail */ + if (count_links > NIS_MAXLINKS) + { + NIS_RES_STATUS (res) = NIS_LINKNAMEERROR; + break; + } + ++count_links; + req.ns_name = + strdupa (NIS_RES_OBJECT (res)->LI_data.li_name); + + /* The following is a non-obvious optimization. A + nis_freeresult call would call xdr_free as the + following code. But it also would unnecessarily + free the result structure. We avoid this here + along with the necessary tests. */ + xdr_free ((xdrproc_t) _xdr_nis_result, (char *) res); + memset (res, '\0', sizeof (*res)); + + link_first_try = 1; /* Try at first the old binding */ + goto again; + } + } + else + if (NIS_RES_STATUS (res) == NIS_SYSTEMERROR + || NIS_RES_STATUS (res) == NIS_NOSUCHNAME + || NIS_RES_STATUS (res) == NIS_NOT_ME) + { + if (link_first_try) + { + __nisbind_destroy (&bptr); + nis_free_directory (dir); + /* Otherwise __nisfind_server will not do anything. */ + dir = NULL; + + if (__nisfind_server (req.ns_name, 1, &dir, &bptr, + flags & ~MASTER_ONLY) + != NIS_SUCCESS) + goto out; + } + else + if (__nisbind_next (&bptr) != NIS_SUCCESS) + { + /* No more servers to search. Try parent. */ + const char *ndomain = __nis_domain_of (req.ns_name); + req.ns_name = strdupa (ndomain); + if (strcmp (req.ns_name, ".") == 0) + { + NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE; + goto out; + } + + __nisbind_destroy (&bptr); + nis_free_directory (dir); + dir = NULL; + status = __prepare_niscall (req.ns_name, &dir, + &bptr, flags); + if (status != NIS_SUCCESS) + { + NIS_RES_STATUS (res) = status; + goto out; + } + goto again; + } + + while (__nisbind_connect (&bptr) != NIS_SUCCESS) + { + if (__nisbind_next (&bptr) != NIS_SUCCESS) + { + nis_free_directory (dir); + goto out; + } + } + goto again; + } + break; + } + link_first_try = 0; /* Set it back */ + } + while ((flags & HARD_LOOKUP) && status == NIS_RPCERROR); + + __nisbind_destroy (&bptr); + nis_free_directory (dir); + + if (status != NIS_SUCCESS) + { + NIS_RES_STATUS (res) = status; + goto out; + } + + switch (NIS_RES_STATUS (res)) + { + case NIS_PARTIAL: + case NIS_SUCCESS: + case NIS_S_SUCCESS: + case NIS_LINKNAMEERROR: /* We follow to max links */ + case NIS_UNAVAIL: /* NIS+ is not installed, or all servers are down */ + ++done; + break; + default: + /* Try the next domainname if we don't follow a link */ + if (count_links) + { + free (req.ns_name); + NIS_RES_STATUS (res) = NIS_LINKNAMEERROR; + ++done; + break; + } + ++name_nr; + if (names[name_nr] == NULL) + { + ++done; + break; + } + req.ns_name = names[name_nr]; + break; + } + } + + out: + if (names != namebuf) + nis_freenames (names); + + return res; +} diff --git a/src/nisplus/nis_mkdir.c b/src/nisplus/nis_mkdir.c new file mode 100644 index 0000000..ab8361b --- /dev/null +++ b/src/nisplus/nis_mkdir.c @@ -0,0 +1,45 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "nis_intern.h" +#include "nis_xdr.h" + + +nis_error +nis_mkdir (const_nis_name dir, const nis_server *server) +{ + nis_error res, res2; + + if (server == NULL) + res2 = __do_niscall (dir, NIS_MKDIR, (xdrproc_t) _xdr_nis_name, + (caddr_t) &dir, (xdrproc_t) _xdr_nis_error, + (caddr_t) &res, 0, NULL); + else + res2 = __do_niscall2 (server, 1, NIS_MKDIR, + (xdrproc_t) _xdr_nis_name, + (caddr_t) &dir, (xdrproc_t) _xdr_nis_error, + (caddr_t) &res, 0, NULL); + if (res2 != NIS_SUCCESS) + return res2; + + return res; +} diff --git a/src/nisplus/nis_modify.c b/src/nisplus/nis_modify.c new file mode 100644 index 0000000..35e7aea --- /dev/null +++ b/src/nisplus/nis_modify.c @@ -0,0 +1,75 @@ +/* Copyright (C) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "nis_intern.h" +#include "nis_xdr.h" + +nis_result * +nis_modify (const_nis_name name, const nis_object *obj2) +{ + nis_object obj; + nis_result *res; + nis_error status; + struct ns_request req; + size_t namelen = strlen (name); + char buf1[namelen + 20]; + char buf4[namelen + 20]; + + res = calloc (1, sizeof (nis_result)); + if (res == NULL) + return NULL; + + req.ns_name = (char *) name; + + memcpy (&obj, obj2, sizeof (nis_object)); + + if (obj.zo_name == NULL || obj.zo_name[0] == '\0') + obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1)); + + if (obj.zo_owner == NULL || obj.zo_owner[0] == '\0') + obj.zo_owner = nis_local_principal (); + + if (obj.zo_group == NULL || obj.zo_group[0] == '\0') + obj.zo_group = nis_local_group (); + + obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4)); + + req.ns_object.ns_object_val = nis_clone_object (&obj, NULL); + if (req.ns_object.ns_object_val == NULL) + { + NIS_RES_STATUS (res) = NIS_NOMEMORY; + return res; + } + req.ns_object.ns_object_len = 1; + + status = __do_niscall (name, NIS_MODIFY, (xdrproc_t) _xdr_ns_request, + (caddr_t) & req, (xdrproc_t) _xdr_nis_result, + (caddr_t) res, MASTER_ONLY, + NULL); + if (status != NIS_SUCCESS) + NIS_RES_STATUS (res) = status; + + nis_destroy_object (req.ns_object.ns_object_val); + + return res; +} diff --git a/src/nisplus/nis_ping.c b/src/nisplus/nis_ping.c new file mode 100644 index 0000000..1cfcf1f --- /dev/null +++ b/src/nisplus/nis_ping.c @@ -0,0 +1,71 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "nis_intern.h" +#include "nis_xdr.h" + +void +nis_ping (const_nis_name dirname, unsigned int utime, + const nis_object *dirobj) +{ + nis_result *res = NULL; + nis_object *obj; + ping_args args; + unsigned int i; + + if (dirname == NULL && dirobj == NULL) + abort (); + + if (dirobj == NULL) + { + res = nis_lookup (dirname, MASTER_ONLY); + if (res == NULL || NIS_RES_STATUS (res) != NIS_SUCCESS) + { + nis_freeresult (res); + return; + } + obj = res->objects.objects_val; + } + else + obj = (nis_object *) dirobj; + + /* Check if obj is really a diryectory object */ + if (__type_of (obj) != NIS_DIRECTORY_OBJ) + { + nis_freeresult (res); + return; + } + + if (dirname == NULL) + args.dir = obj->DI_data.do_name; + else + args.dir = (char *) dirname; + args.stamp = utime; + + /* Send the ping only to replicas */ + for (i = 1; i < obj->DI_data.do_servers.do_servers_len; ++i) + __do_niscall2 (&obj->DI_data.do_servers.do_servers_val[i], 1, + NIS_PING, (xdrproc_t) _xdr_ping_args, + (caddr_t) &args, (xdrproc_t) xdr_void, + (caddr_t) NULL, 0, NULL); + nis_freeresult (res); +} diff --git a/src/nisplus/nis_print.c b/src/nisplus/nis_print.c new file mode 100644 index 0000000..8a804dd --- /dev/null +++ b/src/nisplus/nis_print.c @@ -0,0 +1,391 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include "nis_intern.h" + +#ifndef _ +#define _(String) gettext (String) +#endif + +#ifndef N_ +#define N_(String) String +#endif + +static const char * +nis_nstype2str (const nstype type) +{ + +/* Name service names mustn't be translated, only UNKNOWN needs it */ + + switch (type) + { + case NIS: + return "NIS"; + case SUNYP: + return "SUNYP"; + case IVY: + return "IVY"; + case DNS: + return "DNS"; + case X500: + return "X500"; + case DNANS: + return "DNANS"; + case XCHS: + return "XCHS"; + case CDS: + return "CDS"; + default: + return N_("UNKNOWN"); + } +} + +static void +print_ttl (const uint32_t ttl) +{ + uint32_t time, s, m, h; + + time = ttl; + + h = time / (60 * 60); + time %= (60 * 60); + m = time / 60; + time %= 60; + s = time; + printf ("%u:%u:%u\n", h, m, s); +} + +static void +print_flags (const unsigned int flags) +{ + fputs ("(", stdout); + + if (flags & TA_SEARCHABLE) + fputs ("SEARCHABLE, ", stdout); + + if (flags & TA_BINARY) + { + fputs ("BINARY DATA", stdout); + if (flags & TA_XDR) + fputs (", XDR ENCODED", stdout); + if (flags & TA_ASN1) + fputs (", ASN.1 ENCODED", stdout); + if (flags & TA_CRYPT) + fputs (", ENCRYPTED", stdout); + } + else + { + fputs ("TEXTUAL DATA", stdout); + if (flags & TA_SEARCHABLE) + { + if (flags & TA_CASE) + fputs (", CASE INSENSITIVE", stdout); + else + fputs (", CASE SENSITIVE", stdout); + } + } + + fputs (")\n", stdout); +} + +static void +nis_print_objtype (enum zotypes type) +{ + switch (type) + { + case NIS_BOGUS_OBJ: + fputs (_("BOGUS OBJECT\n"), stdout); + break; + case NIS_NO_OBJ: + fputs (_("NO OBJECT\n"), stdout); + break; + case NIS_DIRECTORY_OBJ: + fputs (_("DIRECTORY\n"), stdout); + break; + case NIS_GROUP_OBJ: + fputs (_("GROUP\n"), stdout); + break; + case NIS_TABLE_OBJ: + fputs (_("TABLE\n"), stdout); + break; + case NIS_ENTRY_OBJ: + fputs (_("ENTRY\n"), stdout); + break; + case NIS_LINK_OBJ: + fputs (_("LINK\n"), stdout); + break; + case NIS_PRIVATE_OBJ: + fputs (_("PRIVATE\n"), stdout); + break; + default: + fputs (_("(Unknown object)\n"), stdout); + break; + } +} + +void +nis_print_rights (const unsigned int access) +{ + char result[17]; + unsigned int acc; + int i; + + acc = access; /* Parameter is const ! */ + result[i = 16] = '\0'; + while (i > 0) + { + i -= 4; + result[i + 0] = (acc & NIS_READ_ACC) ? 'r' : '-'; + result[i + 1] = (acc & NIS_MODIFY_ACC) ? 'm' : '-'; + result[i + 2] = (acc & NIS_CREATE_ACC) ? 'c' : '-'; + result[i + 3] = (acc & NIS_DESTROY_ACC) ? 'd' : '-'; + + acc >>= 8; + } + fputs (result, stdout); +} + + +void +nis_print_directory (const directory_obj *dir) +{ + nis_server *sptr; + unsigned int i; + + printf (_("Name : `%s'\n"), dir->do_name); + printf (_("Type : %s\n"), nis_nstype2str (dir->do_type)); + sptr = dir->do_servers.do_servers_val; + for (i = 0; i < dir->do_servers.do_servers_len; i++) + { + if (i == 0) + fputs (_("Master Server :\n"), stdout); + else + fputs (_("Replicate :\n"), stdout); + printf (_("\tName : %s\n"), sptr->name); + fputs (_("\tPublic Key : "), stdout); + switch (sptr->key_type) + { + case NIS_PK_NONE: + fputs (_("None.\n"), stdout); + break; + case NIS_PK_DH: + printf (_("Diffie-Hellmann (%d bits)\n"), + (sptr->pkey.n_len - 1) * 4); + /* sptr->pkey.n_len counts the last 0, too */ + break; + case NIS_PK_RSA: + printf (_("RSA (%d bits)\n"), (sptr->pkey.n_len - 1) * 4); + break; + case NIS_PK_KERB: + fputs (_("Kerberos.\n"), stdout); + break; + default: + printf (_("Unknown (type = %d, bits = %d)\n"), sptr->key_type, + (sptr->pkey.n_len - 1) * 4); + break; + } + + if (sptr->ep.ep_len != 0) + { + unsigned int j; + + endpoint *ptr; + ptr = sptr->ep.ep_val; + printf (_("\tUniversal addresses (%u)\n"), sptr->ep.ep_len); + for (j = 0; j < sptr->ep.ep_len; j++) + { + printf ("\t[%d] - ", j + 1); + if (ptr->proto != NULL && ptr->proto[0] != '\0') + printf ("%s, ", ptr->proto); + else + printf ("-, "); + if (ptr->family != NULL && ptr->family[0] != '\0') + printf ("%s, ", ptr->family); + else + printf ("-, "); + if (ptr->uaddr != NULL && ptr->uaddr[0] != '\0') + printf ("%s\n", ptr->uaddr); + else + fputs ("-\n", stdout); + ptr++; + } + } + sptr++; + } + + fputs (_("Time to live : "), stdout); + print_ttl (dir->do_ttl); + fputs (_("Default Access rights :\n"), stdout); + if (dir->do_armask.do_armask_len != 0) + { + oar_mask *ptr; + + ptr = dir->do_armask.do_armask_val; + for (i = 0; i < dir->do_armask.do_armask_len; i++) + { + nis_print_rights (ptr->oa_rights); + printf (_("\tType : %s\n"), nis_nstype2str (ptr->oa_otype)); + fputs (_("\tAccess rights: "), stdout); + nis_print_rights (ptr->oa_rights); + fputs ("\n", stdout); + ptr++; + } + } +} + + +void +nis_print_group (const group_obj *obj) +{ + unsigned int i; + + fputs (_("Group Flags :"), stdout); + if (obj->gr_flags) + printf ("0x%08X", obj->gr_flags); + fputs (_("\nGroup Members :\n"), stdout); + + for (i = 0; i < obj->gr_members.gr_members_len; i++) + printf ("\t%s\n", obj->gr_members.gr_members_val[i]); +} + + +void +nis_print_table (const table_obj *obj) +{ + unsigned int i; + + printf (_("Table Type : %s\n"), obj->ta_type); + printf (_("Number of Columns : %d\n"), obj->ta_maxcol); + printf (_("Character Separator : %c\n"), obj->ta_sep); + printf (_("Search Path : %s\n"), obj->ta_path); + fputs (_("Columns :\n"), stdout); + for (i = 0; i < obj->ta_cols.ta_cols_len; i++) + { + printf (_("\t[%d]\tName : %s\n"), i, + obj->ta_cols.ta_cols_val[i].tc_name); + fputs (_("\t\tAttributes : "), stdout); + print_flags (obj->ta_cols.ta_cols_val[i].tc_flags); + fputs (_("\t\tAccess Rights : "), stdout); + nis_print_rights (obj->ta_cols.ta_cols_val[i].tc_rights); + fputc ('\n', stdout); + } +} + + +void +nis_print_link (const link_obj *obj) +{ + fputs (_("Linked Object Type : "), stdout); + nis_print_objtype (obj->li_rtype); + printf (_("Linked to : %s\n"), obj->li_name); + /* XXX Print the attributes here, if they exists */ +} + + +void +nis_print_entry (const entry_obj *obj) +{ + unsigned int i; + + printf (_("\tEntry data of type %s\n"), obj->en_type); + for (i = 0; i < obj->en_cols.en_cols_len; i++) + { + printf (_("\t[%u] - [%u bytes] "), i, + obj->en_cols.en_cols_val[i].ec_value.ec_value_len); + if ((obj->en_cols.en_cols_val[i].ec_flags & EN_CRYPT) == EN_CRYPT) + fputs (_("Encrypted data\n"), stdout); + else if ((obj->en_cols.en_cols_val[i].ec_flags & EN_BINARY) == EN_BINARY) + fputs (_("Binary data\n"), stdout); + else if (obj->en_cols.en_cols_val[i].ec_value.ec_value_len == 0) + fputs ("'(nil)'\n", stdout); + else + printf ("'%.*s'\n", + (int)obj->en_cols.en_cols_val[i].ec_value.ec_value_len, + obj->en_cols.en_cols_val[i].ec_value.ec_value_val); + } +} + + +void +nis_print_object (const nis_object * obj) +{ + time_t buf; + + printf (_("Object Name : %s\n"), obj->zo_name); + printf (_("Directory : %s\n"), obj->zo_domain); + printf (_("Owner : %s\n"), obj->zo_owner); + printf (_("Group : %s\n"), obj->zo_group); + fputs (_("Access Rights : "), stdout); + nis_print_rights (obj->zo_access); + printf (_("\nTime to Live : ")); + print_ttl (obj->zo_ttl); + buf = obj->zo_oid.ctime; + printf (_("Creation Time : %s"), ctime (&buf)); + buf = obj->zo_oid.mtime; + printf (_("Mod. Time : %s"), ctime (&buf)); + fputs (_("Object Type : "), stdout); + nis_print_objtype (obj->zo_data.zo_type); + switch (obj->zo_data.zo_type) + { + case NIS_DIRECTORY_OBJ: + nis_print_directory (&obj->zo_data.objdata_u.di_data); + break; + case NIS_GROUP_OBJ: + nis_print_group (&obj->zo_data.objdata_u.gr_data); + break; + case NIS_TABLE_OBJ: + nis_print_table (&obj->zo_data.objdata_u.ta_data); + break; + case NIS_ENTRY_OBJ: + nis_print_entry (&obj->zo_data.objdata_u.en_data); + break; + case NIS_LINK_OBJ: + nis_print_link (&obj->zo_data.objdata_u.li_data); + break; + case NIS_PRIVATE_OBJ: + printf (_(" Data Length = %u\n"), + obj->zo_data.objdata_u.po_data.po_data_len); + break; + default: + break; + } +} + + +void +nis_print_result (const nis_result *res) +{ + unsigned int i; + + printf (_("Status : %s\n"), nis_sperrno (NIS_RES_STATUS (res))); + printf (_("Number of objects : %u\n"), res->objects.objects_len); + + for (i = 0; i < res->objects.objects_len; i++) + { + printf (_("Object #%d:\n"), i); + nis_print_object (&res->objects.objects_val[i]); + } +} diff --git a/src/nisplus/nis_print_group_entry.c b/src/nisplus/nis_print_group_entry.c new file mode 100644 index 0000000..5ec4f47 --- /dev/null +++ b/src/nisplus/nis_print_group_entry.c @@ -0,0 +1,183 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#ifndef _ +#define _(String) gettext (String) +#endif + + +void +nis_print_group_entry (const_nis_name group) +{ + if (group != NULL && group[0] != '\0') + { + size_t grouplen = strlen (group); + char buf[grouplen + 50]; + char leafbuf[grouplen + 3]; + char domainbuf[grouplen + 3]; + nis_result *res; + char *cp, *cp2; + u_int i; + + cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1)); + cp = stpcpy (cp, ".groups_dir"); + cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); + if (cp2 != NULL && cp2[0] != '\0') + { + *cp++ = '.'; + stpcpy (cp, cp2); + } + res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME); + + if (res == NULL) + return; + + if (NIS_RES_STATUS (res) != NIS_SUCCESS + || NIS_RES_NUMOBJ (res) != 1 + || __type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ) + { + nis_freeresult (res); + return; + } + + char *mem_exp[NIS_RES_NUMOBJ (res)]; + char *mem_imp[NIS_RES_NUMOBJ (res)]; + char *mem_rec[NIS_RES_NUMOBJ (res)]; + char *nomem_exp[NIS_RES_NUMOBJ (res)]; + char *nomem_imp[NIS_RES_NUMOBJ (res)]; + char *nomem_rec[NIS_RES_NUMOBJ (res)]; + unsigned long mem_exp_cnt = 0, mem_imp_cnt = 0, mem_rec_cnt = 0; + unsigned long nomem_exp_cnt = 0, nomem_imp_cnt = 0, nomem_rec_cnt = 0; + + for (i = 0; + i < NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len; ++i) + { + char *grmem = + NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[i]; + int neg = grmem[0] == '-'; + + switch (grmem[neg]) + { + case '*': + if (neg) + { + nomem_imp[nomem_imp_cnt] = grmem; + ++nomem_imp_cnt; + } + else + { + mem_imp[mem_imp_cnt] = grmem; + ++mem_imp_cnt; + } + break; + case '@': + if (neg) + { + nomem_rec[nomem_rec_cnt] = grmem; + ++nomem_rec_cnt; + } + else + { + mem_rec[mem_rec_cnt] = grmem; + ++mem_rec_cnt; + } + break; + default: + if (neg) + { + nomem_exp[nomem_exp_cnt] = grmem; + ++nomem_exp_cnt; + } + else + { + mem_exp[mem_exp_cnt] = grmem; + ++mem_exp_cnt; + } + break; + } + } + { + char buf2[strlen (NIS_RES_OBJECT (res)->zo_domain) + 10]; + printf (_("Group entry for \"%s.%s\" group:\n"), + NIS_RES_OBJECT (res)->zo_name, + nis_domain_of_r (NIS_RES_OBJECT (res)->zo_domain, + buf2, strlen (NIS_RES_OBJECT (res)->zo_domain) + + 10)); + } + if (mem_exp_cnt) + { + fputs (_(" Explicit members:\n"), stdout); + for (i = 0; i < mem_exp_cnt; ++i) + printf ("\t%s\n", mem_exp[i]); + } + else + fputs (_(" No explicit members\n"), stdout); + if (mem_imp_cnt) + { + fputs (_(" Implicit members:\n"), stdout); + for (i = 0; i < mem_imp_cnt; ++i) + printf ("\t%s\n", &mem_imp[i][2]); + } + else + fputs (_(" No implicit members\n"), stdout); + if (mem_rec_cnt) + { + fputs (_(" Recursive members:\n"), stdout); + for (i = 0; i < mem_rec_cnt; ++i) + printf ("\t%s\n", &mem_rec[i][1]); + } + else + fputs (_(" No recursive members\n"), stdout); + if (nomem_exp_cnt) + { + fputs (_(" Explicit nonmembers:\n"), stdout); + for (i = 0; i < nomem_exp_cnt; ++i) + printf ("\t%s\n", &nomem_exp[i][1]); + } + else + fputs (_(" No explicit nonmembers\n"), stdout); + if (nomem_imp_cnt) + { + fputs (_(" Implicit nonmembers:\n"), stdout); + for (i = 0; i < nomem_imp_cnt; ++i) + printf ("\t%s\n", &nomem_imp[i][3]); + } + else + fputs (_(" No implicit nonmembers\n"), stdout); + if (nomem_rec_cnt) + { + fputs (_(" Recursive nonmembers:\n"), stdout); + for (i = 0; i < nomem_rec_cnt; ++i) + printf ("\t%s=n", &nomem_rec[i][2]); + } + else + fputs (_(" No recursive nonmembers\n"), stdout); + + nis_freeresult (res); + } +} diff --git a/src/nisplus/nis_remove.c b/src/nisplus/nis_remove.c new file mode 100644 index 0000000..17819e1 --- /dev/null +++ b/src/nisplus/nis_remove.c @@ -0,0 +1,59 @@ +/* Copyright (C) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "nis_intern.h" +#include "nis_xdr.h" + +nis_result * +nis_remove (const_nis_name name, const nis_object *obj) +{ + nis_result *res; + nis_error status; + struct ns_request req; + + res = calloc (1, sizeof (nis_result)); + if (res == NULL) + return NULL; + + req.ns_name = (char *)name; + + if (obj != NULL) + { + req.ns_object.ns_object_len = 1; + req.ns_object.ns_object_val = nis_clone_object (obj, NULL); + } + else + { + req.ns_object.ns_object_len = 0; + req.ns_object.ns_object_val = NULL; + } + + if ((status = __do_niscall (name, NIS_REMOVE, (xdrproc_t) _xdr_ns_request, + (caddr_t) &req, (xdrproc_t) _xdr_nis_result, + (caddr_t) res, MASTER_ONLY, + NULL)) != NIS_SUCCESS) + NIS_RES_STATUS (res) = status; + + nis_destroy_object (req.ns_object.ns_object_val); + + return res; +} diff --git a/src/nisplus/nis_removemember.c b/src/nisplus/nis_removemember.c new file mode 100644 index 0000000..671731f --- /dev/null +++ b/src/nisplus/nis_removemember.c @@ -0,0 +1,96 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +nis_error +nis_removemember (const_nis_name member, const_nis_name group) +{ + if (group != NULL && group[0] != '\0') + { + size_t grouplen = strlen (group); + char buf[grouplen + 14 + NIS_MAXNAMELEN]; + char domainbuf[grouplen + 2]; + nis_result *res, *res2; + nis_error status; + char *cp, *cp2; + + cp = nis_leaf_of_r (group, buf, sizeof (buf) - 1); + cp += strlen(cp); + cp = stpcpy (cp, ".groups_dir"); + cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); + if (cp2 != NULL && cp2[0] != '\0') + { + cp = stpcpy (cp, "."); + stpcpy (cp, cp2); + } + res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME); + if (res == NULL) + return NIS_NOMEMORY; + if (NIS_RES_STATUS (res) != NIS_SUCCESS) + { + status = NIS_RES_STATUS (res); + nis_freeresult (res); + return status; + } + + if (NIS_RES_NUMOBJ (res) != 1 + || __type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ) + { + nis_freeresult (res); + return NIS_INVALIDOBJ; + } + + nis_name *gr_members_val + = NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_val; + u_int gr_members_len + = NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len; + + u_int i, j = 0; + for (i = 0; i < gr_members_len; ++i) + if (strcmp (gr_members_val[i], member) != 0) + gr_members_val[j++] = gr_members_val[i]; + else + free (gr_members_val[i]); + + /* There is no need to reallocate the gr_members_val array. We + just adjust the size to match the number of strings still in + it. Yes, xdr_array will use mem_free with a size parameter + but this is mapped to a simple free call which determines the + size of the block by itself. */ + NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len = j; + + cp = stpcpy (buf, NIS_RES_OBJECT (res)->zo_name); + *cp++ = '.'; + strncpy (cp, NIS_RES_OBJECT (res)->zo_domain, NIS_MAXNAMELEN); + res2 = nis_modify (buf, NIS_RES_OBJECT (res)); + status = NIS_RES_STATUS (res2); + nis_freeresult (res); + nis_freeresult (res2); + + return status; + } + else + return NIS_FAIL; +} diff --git a/src/nisplus/nis_rmdir.c b/src/nisplus/nis_rmdir.c new file mode 100644 index 0000000..14d62dd --- /dev/null +++ b/src/nisplus/nis_rmdir.c @@ -0,0 +1,42 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "nis_intern.h" +#include "nis_xdr.h" + +nis_error +nis_rmdir (const_nis_name dir, const nis_server *server) +{ + nis_error res, res2; + + if (server == NULL) + return NIS_SYSTEMERROR; + + res2 = __do_niscall2 (server, 1, NIS_RMDIR, + (xdrproc_t) _xdr_nis_name, + (caddr_t) &dir, (xdrproc_t) _xdr_nis_error, + (caddr_t) &res, 0, NULL); + if (res2 != NIS_SUCCESS) + return res2; + + return res; +} diff --git a/src/nisplus/nis_server.c b/src/nisplus/nis_server.c new file mode 100644 index 0000000..80acaaa --- /dev/null +++ b/src/nisplus/nis_server.c @@ -0,0 +1,87 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "nis_intern.h" +#include "nis_xdr.h" + +nis_error +nis_servstate (const nis_server *serv, const nis_tag *tags, + const int numtags, nis_tag **result) +{ + nis_taglist taglist; + nis_taglist tagres; + + *result = 0; + tagres.tags.tags_len = 0; + tagres.tags.tags_val = NULL; + taglist.tags.tags_len = numtags; + taglist.tags.tags_val = (nis_tag *) tags; + + if (serv == NULL) + return NIS_BADOBJECT; + + if (__do_niscall2 (serv, 1, NIS_SERVSTATE, (xdrproc_t) _xdr_nis_taglist, + (caddr_t) &taglist, (xdrproc_t) _xdr_nis_taglist, + (caddr_t) &tagres, 0, NULL) != NIS_SUCCESS) + return NIS_RPCERROR; + + *result = tagres.tags.tags_val; + + return NIS_SUCCESS; +} + +nis_error +nis_stats (const nis_server *serv, const nis_tag *tags, + const int numtags, nis_tag **result) +{ + nis_taglist taglist; + nis_taglist tagres; + + *result = NULL; + tagres.tags.tags_len = 0; + tagres.tags.tags_val = NULL; + taglist.tags.tags_len = numtags; + taglist.tags.tags_val = (nis_tag *) tags; + + if (serv == NULL) + return NIS_BADOBJECT; + + if (__do_niscall2 (serv, 1, NIS_STATUS, (xdrproc_t) _xdr_nis_taglist, + (caddr_t) &taglist, (xdrproc_t) _xdr_nis_taglist, + (caddr_t) &tagres, 0, NULL) != NIS_SUCCESS) + return NIS_RPCERROR; + + *result = tagres.tags.tags_val; + + return NIS_SUCCESS; +} + +void +nis_freetags (nis_tag *tags, const int numtags) +{ + int i; + + for (i = 0; i < numtags; ++i) + free (tags[i].tag_val); + free (tags); +} diff --git a/src/nisplus/nis_subr.c b/src/nisplus/nis_subr.c new file mode 100644 index 0000000..c6d4971 --- /dev/null +++ b/src/nisplus/nis_subr.c @@ -0,0 +1,356 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +nis_name +nis_leaf_of (const_nis_name name) +{ + static char result[NIS_MAXNAMELEN + 1]; + + return nis_leaf_of_r (name, result, NIS_MAXNAMELEN); +} + +nis_name +nis_leaf_of_r (const_nis_name name, char *buffer, size_t buflen) +{ + size_t i = 0; + + buffer[0] = '\0'; + + while (name[i] != '.' && name[i] != '\0') + i++; + + if (i >= buflen) + { + errno = ERANGE; + return NULL; + } + + *((char *) mempcpy (buffer, name, i)) = '\0'; + + return buffer; +} + + +nis_name +nis_name_of (const_nis_name name) +{ + static char result[NIS_MAXNAMELEN + 1]; + + return nis_name_of_r (name, result, NIS_MAXNAMELEN); +} + + +nis_name +nis_name_of_r (const_nis_name name, char *buffer, size_t buflen) +{ + char *local_domain; + int diff; + + local_domain = nis_local_directory (); + + diff = strlen (name) - strlen (local_domain); + if (diff <= 0) + return NULL; + + if (strcmp (&name[diff], local_domain) != 0) + return NULL; + + if ((size_t) diff >= buflen) + { + errno = ERANGE; + return NULL; + } + + *((char *) mempcpy (buffer, name, diff - 1)) = '\0'; + + if (diff - 1 == 0) + return NULL; + + return buffer; +} + + +static int +count_dots (const_nis_name str) +{ + int count = 0; + size_t i; + + for (i = 0; str[i] != '\0'; ++i) + if (str[i] == '.') + ++count; + + return count; +} + +/* If we run out of memory, we don't give already allocated memory + free. The overhead for bringing getnames back in a safe state to + free it is to big. */ +nis_name * +nis_getnames (const_nis_name name) +{ + const char *local_domain = nis_local_directory (); + size_t local_domain_len = strlen (local_domain); + size_t name_len = strlen (name); + char *path; + int pos = 0; + char *saveptr = NULL; + int have_point; + const char *cp; + const char *cp2; + + int count = 2; + nis_name *getnames = malloc ((count + 1) * sizeof (char *)); + if (getnames == NULL) + return NULL; + + /* Do we have a fully qualified NIS+ name ? If yes, give it back */ + if (name[name_len - 1] == '.') + { + if ((getnames[0] = strdup (name)) == NULL) + { + free_null: + while (pos-- > 0) + free (getnames[pos]); + free (getnames); + return NULL; + } + + getnames[1] = NULL; + + return getnames; + } + + /* If the passed NAME is shared a suffix (the latter of course with + a final dot) with each other we pass back NAME with a final + dot. */ + if (local_domain_len > 2) + { + have_point = 0; + cp = &local_domain[local_domain_len - 2]; + cp2 = &name[name_len - 1]; + + while (*cp == *cp2) + { + if (*cp == '.') + have_point = 1; + --cp; + --cp2; + if (cp < local_domain) + { + have_point = cp2 < name || *cp2 == '.'; + break; + } + if (cp2 < name) + { + have_point = *cp == '.'; + break; + } + } + + if (have_point) + { + getnames[0] = malloc (name_len + 2); + if (getnames[0] == NULL) + goto free_null; + + strcpy (stpcpy (getnames[0], name), "."); + ++pos; + } + } + + /* Get the search path, where we have to search "name" */ + path = getenv ("NIS_PATH"); + if (path == NULL) + path = strdupa ("$"); + else + path = strdupa (path); + + have_point = strchr (name, '.') != NULL; + + cp = strtok_r (path, ":", &saveptr); + while (cp) + { + if (strcmp (cp, "$") == 0) + { + const char *cptr = local_domain; + char *tmp; + + while (*cptr != '\0' && count_dots (cptr) >= 2) + { + if (pos >= count) + { + count += 5; + nis_name *newp = realloc (getnames, + (count + 1) * sizeof (char *)); + if (newp == NULL) + goto free_null; + getnames = newp; + } + tmp = malloc (strlen (cptr) + local_domain_len + name_len + 2); + if (tmp == NULL) + goto free_null; + + getnames[pos] = tmp; + tmp = stpcpy (tmp, name); + *tmp++ = '.'; + if (cptr[1] != '\0') + stpcpy (tmp, cptr); + else + ++cptr; + + ++pos; + + while (*cptr != '.' && *cptr != '\0') + ++cptr; + if (cptr[0] != '\0' && cptr[1] != '\0') + /* If we have only ".", don't remove the "." */ + ++cptr; + } + } + else + { + char *tmp; + size_t cplen = strlen (cp); + + if (cp[cplen - 1] == '$') + { + char *p; + + tmp = malloc (cplen + local_domain_len + name_len + 2); + if (tmp == NULL) + goto free_null; + + p = stpcpy (tmp, name); + *p++ = '.'; + p = mempcpy (p, cp, cplen); + --p; + if (p[-1] != '.') + *p++ = '.'; + stpcpy (p, local_domain); + } + else + { + char *p; + + tmp = malloc (cplen + name_len + 3); + if (tmp == NULL) + goto free_null; + + p = mempcpy (tmp, name, name_len); + *p++ = '.'; + p = mempcpy (p, cp, cplen); + if (p[-1] != '.') + *p++ = '.'; + *p = '\0'; + } + + if (pos >= count) + { + count += 5; + nis_name *newp = realloc (getnames, + (count + 1) * sizeof (char *)); + if (newp == NULL) + goto free_null; + getnames = newp; + } + getnames[pos] = tmp; + ++pos; + } + cp = strtok_r (NULL, ":", &saveptr); + } + + if (pos == 0 + && asprintf (&getnames[pos++], "%s%s%s%s", + name, name[name_len - 1] == '.' ? "" : ".", + local_domain, + local_domain[local_domain_len - 1] == '.' ? "" : ".") < 0) + goto free_null; + + getnames[pos] = NULL; + + return getnames; +} + + +void +nis_freenames (nis_name *names) +{ + int i = 0; + + while (names[i] != NULL) + { + free (names[i]); + ++i; + } + + free (names); +} + + +name_pos +nis_dir_cmp (const_nis_name n1, const_nis_name n2) +{ + int len1, len2; + + len1 = strlen (n1); + len2 = strlen (n2); + + if (len1 == len2) + { + if (strcmp (n1, n2) == 0) + return SAME_NAME; + else + return NOT_SEQUENTIAL; + } + + if (len1 < len2) + { + if (n2[len2 - len1 - 1] != '.') + return NOT_SEQUENTIAL; + else if (strcmp (&n2[len2 - len1], n1) == 0) + return HIGHER_NAME; + else + return NOT_SEQUENTIAL; + } + else + { + if (n1[len1 - len2 - 1] != '.') + return NOT_SEQUENTIAL; + else if (strcmp (&n1[len1 - len2], n2) == 0) + return LOWER_NAME; + else + return NOT_SEQUENTIAL; + + } +} + + +void +nis_destroy_object (nis_object *obj) +{ + nis_free_object (obj); +} diff --git a/src/nisplus/nis_table.c b/src/nisplus/nis_table.c new file mode 100644 index 0000000..659d388 --- /dev/null +++ b/src/nisplus/nis_table.c @@ -0,0 +1,804 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include "nis_intern.h" +#include "nis_xdr.h" + +/* this functions are internal, but used by libnss_nisplus plugin */ +extern struct ib_request * +__create_ib_request (const_nis_name name, unsigned int flags); +extern nis_error +__follow_path (char **tablepath, char **tableptr, struct ib_request *ibreq, + dir_binding *bptr); + + +struct ib_request * +__create_ib_request (const_nis_name name, unsigned int flags) +{ + struct ib_request *ibreq = calloc (1, sizeof (struct ib_request)); + nis_attr *search_val = NULL; + size_t search_len = 0; + size_t size = 0; + + if (ibreq == NULL) + return NULL; + + ibreq->ibr_flags = flags; + + char *cptr = strdupa (name); + + /* Not of "[key=value,key=value,...],foo.." format? */ + if (cptr[0] != '[') + { + ibreq->ibr_name = strdup (cptr); + if (ibreq->ibr_name == NULL) + { + free (ibreq); + return NULL; + } + return ibreq; + } + + /* "[key=value,...],foo" format */ + ibreq->ibr_name = strchr (cptr, ']'); + if (ibreq->ibr_name == NULL || ibreq->ibr_name[1] != ',') + { + /* The object has not really been built yet so we use free. */ + free (ibreq); + return NULL; + } + + /* Check if we have an entry of "[key=value,],bar". If, remove the "," */ + if (ibreq->ibr_name[-1] == ',') + ibreq->ibr_name[-1] = '\0'; + else + ibreq->ibr_name[0] = '\0'; + ibreq->ibr_name += 2; + ibreq->ibr_name = strdup (ibreq->ibr_name); + if (ibreq->ibr_name == NULL) + { + free_null: + while (search_len-- > 0) + { + free (search_val[search_len].zattr_ndx); + free (search_val[search_len].zattr_val.zattr_val_val); + } + free (search_val); + nis_free_request (ibreq); + return NULL; + } + + ++cptr; /* Remove "[" */ + + while (cptr != NULL && cptr[0] != '\0') + { + char *key = cptr; + char *val = strchr (cptr, '='); + + cptr = strchr (key, ','); + if (cptr != NULL) + *cptr++ = '\0'; + + if (val == NULL) + { + nis_free_request (ibreq); + return NULL; + } + *val++ = '\0'; + if (search_len + 1 >= size) + { + size += 1; + nis_attr *newp = realloc (search_val, size * sizeof (nis_attr)); + if (newp == NULL) + goto free_null; + search_val = newp; + } + search_val[search_len].zattr_ndx = strdup (key); + if (search_val[search_len].zattr_ndx == NULL) + goto free_null; + + search_val[search_len].zattr_val.zattr_val_len = strlen (val) + 1; + search_val[search_len].zattr_val.zattr_val_val = strdup (val); + if (search_val[search_len].zattr_val.zattr_val_val == NULL) + { + free (search_val[search_len].zattr_ndx); + goto free_null; + } + + ++search_len; + } + + ibreq->ibr_srch.ibr_srch_val = search_val; + ibreq->ibr_srch.ibr_srch_len = search_len; + + return ibreq; +} + +static const struct timeval RPCTIMEOUT = {10, 0}; + +static char * +get_tablepath (char *name, dir_binding *bptr) +{ + enum clnt_stat result; + nis_result res; + struct ns_request req; + + memset (&res, '\0', sizeof (res)); + + req.ns_name = name; + req.ns_object.ns_object_len = 0; + req.ns_object.ns_object_val = NULL; + + result = clnt_call (bptr->clnt, NIS_LOOKUP, (xdrproc_t) _xdr_ns_request, + (caddr_t) &req, (xdrproc_t) _xdr_nis_result, + (caddr_t) &res, RPCTIMEOUT); + + const char *cptr; + if (result == RPC_SUCCESS && NIS_RES_STATUS (&res) == NIS_SUCCESS + && __type_of (NIS_RES_OBJECT (&res)) == NIS_TABLE_OBJ) + cptr = NIS_RES_OBJECT (&res)->TA_data.ta_path; + else + cptr = ""; + + char *str = strdup (cptr); + + if (result == RPC_SUCCESS) + xdr_free ((xdrproc_t) _xdr_nis_result, (char *) &res); + + return str; +} + + +nis_error +__follow_path (char **tablepath, char **tableptr, struct ib_request *ibreq, + dir_binding *bptr) +{ + if (*tablepath == NULL) + { + *tablepath = get_tablepath (ibreq->ibr_name, bptr); + if (*tablepath == NULL) + return NIS_NOMEMORY; + + *tableptr = *tablepath; + } + if (*tableptr == NULL) + return NIS_NOTFOUND; + + char *newname = strsep (tableptr, ":"); + if (newname[0] == '\0') + return NIS_NOTFOUND; + + newname = strdup (newname); + if (newname == NULL) + return NIS_NOMEMORY; + + free (ibreq->ibr_name); + ibreq->ibr_name = newname; + + return NIS_SUCCESS; +} + + +nis_result * +nis_list (const_nis_name name, unsigned int flags, + int (*callback) (const_nis_name name, + const nis_object *object, + const void *userdata), + const void *userdata) +{ + nis_result *res = malloc (sizeof (nis_result)); + ib_request *ibreq; + int status; + enum clnt_stat clnt_status; + int count_links = 0; /* We will only follow NIS_MAXLINKS links! */ + int done = 0; + nis_name *names; + nis_name namebuf[2] = {NULL, NULL}; + int name_nr = 0; + nis_cb *cb = NULL; + char *tableptr; + char *tablepath = NULL; + int first_try = 0; /* Do we try the old binding at first ? */ + nis_result *allres = NULL; + + if (res == NULL) + return NULL; + + if (name == NULL) + { + status = NIS_BADNAME; + err_out: + nis_freeresult (allres); + memset (res, '\0', sizeof (nis_result)); + NIS_RES_STATUS (res) = status; + return res; + } + + ibreq = __create_ib_request (name, flags); + if (ibreq == NULL) + { + status = NIS_BADNAME; + goto err_out; + } + + if ((flags & EXPAND_NAME) + && ibreq->ibr_name[strlen (ibreq->ibr_name) - 1] != '.') + { + names = nis_getnames (ibreq->ibr_name); + free (ibreq->ibr_name); + ibreq->ibr_name = NULL; + if (names == NULL) + { + nis_free_request (ibreq); + status = NIS_BADNAME; + goto err_out; + } + ibreq->ibr_name = strdup (names[name_nr]); + if (ibreq->ibr_name == NULL) + { + nis_freenames (names); + nis_free_request (ibreq); + status = NIS_NOMEMORY; + goto err_out; + } + } + else + { + names = namebuf; + names[name_nr] = ibreq->ibr_name; + } + + cb = NULL; + + while (!done) + { + dir_binding bptr; + directory_obj *dir = NULL; + + memset (res, '\0', sizeof (nis_result)); + + status = __nisfind_server (ibreq->ibr_name, + ibreq->ibr_srch.ibr_srch_val != NULL, + &dir, &bptr, flags & ~MASTER_ONLY); + if (status != NIS_SUCCESS) + { + NIS_RES_STATUS (res) = status; + goto fail3; + } + + while (__nisbind_connect (&bptr) != NIS_SUCCESS) + if (__nisbind_next (&bptr) != NIS_SUCCESS) + { + NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE; + goto fail; + } + + if (callback != NULL) + { + assert (cb == NULL); + cb = __nis_create_callback (callback, userdata, flags); + ibreq->ibr_cbhost.ibr_cbhost_len = 1; + ibreq->ibr_cbhost.ibr_cbhost_val = cb->serv; + } + + again: + clnt_status = clnt_call (bptr.clnt, NIS_IBLIST, + (xdrproc_t) _xdr_ib_request, (caddr_t) ibreq, + (xdrproc_t) _xdr_nis_result, + (caddr_t) res, RPCTIMEOUT); + + if (clnt_status != RPC_SUCCESS) + NIS_RES_STATUS (res) = NIS_RPCERROR; + else + switch (NIS_RES_STATUS (res)) + { /* start switch */ + case NIS_PARTIAL: + case NIS_SUCCESS: + case NIS_S_SUCCESS: + if (__type_of (NIS_RES_OBJECT (res)) == NIS_LINK_OBJ + && (flags & FOLLOW_LINKS)) /* We are following links. */ + { + free (ibreq->ibr_name); + ibreq->ibr_name = NULL; + /* If we hit the link limit, bail. */ + if (count_links > NIS_MAXLINKS) + { + NIS_RES_STATUS (res) = NIS_LINKNAMEERROR; + ++done; + break; + } + ++count_links; + ibreq->ibr_name = + strdup (NIS_RES_OBJECT (res)->LI_data.li_name); + if (ibreq->ibr_name == NULL) + { + NIS_RES_STATUS (res) = NIS_NOMEMORY; + fail: + __nisbind_destroy (&bptr); + nis_free_directory (dir); + fail3: + free (tablepath); + if (cb) + { + __nis_destroy_callback (cb); + ibreq->ibr_cbhost.ibr_cbhost_len = 0; + ibreq->ibr_cbhost.ibr_cbhost_val = NULL; + } + if (names != namebuf) + nis_freenames (names); + nis_free_request (ibreq); + nis_freeresult (allres); + return res; + } + if (NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len) + if (ibreq->ibr_srch.ibr_srch_len == 0) + { + ibreq->ibr_srch.ibr_srch_len = + NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len; + ibreq->ibr_srch.ibr_srch_val = + NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_val; + } + /* The following is a non-obvious optimization. A + nis_freeresult call would call xdr_free as the + following code. But it also would unnecessarily + free the result structure. We avoid this here + along with the necessary tests. */ + xdr_free ((xdrproc_t) _xdr_nis_result, (char *)res); + memset (res, '\0', sizeof (*res)); + first_try = 1; /* Try at first the old binding */ + goto again; + } + else if ((flags & FOLLOW_PATH) + && NIS_RES_STATUS (res) == NIS_PARTIAL) + { + enum nis_error err = __follow_path (&tablepath, &tableptr, + ibreq, &bptr); + if (err != NIS_SUCCESS) + { + if (err == NIS_NOMEMORY) + NIS_RES_STATUS (res) = err; + ++done; + } + else + { + /* The following is a non-obvious optimization. A + nis_freeresult call would call xdr_free as the + following code. But it also would unnecessarily + free the result structure. We avoid this here + along with the necessary tests. */ + xdr_free ((xdrproc_t) _xdr_nis_result, (char *) res); + memset (res, '\0', sizeof (*res)); + first_try = 1; + goto again; + } + } + else if ((flags & (FOLLOW_PATH | ALL_RESULTS)) + == (FOLLOW_PATH | ALL_RESULTS)) + { + if (allres == NULL) + { + allres = res; + res = malloc (sizeof (nis_result)); + if (res == NULL) + { + res = allres; + allres = NULL; + NIS_RES_STATUS (res) = NIS_NOMEMORY; + goto fail; + } + NIS_RES_STATUS (res) = NIS_RES_STATUS (allres); + } + else + { + nis_object *objects_val + = realloc (NIS_RES_OBJECT (allres), + (NIS_RES_NUMOBJ (allres) + + NIS_RES_NUMOBJ (res)) + * sizeof (nis_object)); + if (objects_val == NULL) + { + NIS_RES_STATUS (res) = NIS_NOMEMORY; + goto fail; + } + NIS_RES_OBJECT (allres) = objects_val; + memcpy (NIS_RES_OBJECT (allres) + NIS_RES_NUMOBJ (allres), + NIS_RES_OBJECT (res), + NIS_RES_NUMOBJ (res) * sizeof (nis_object)); + NIS_RES_NUMOBJ (allres) += NIS_RES_NUMOBJ (res); + NIS_RES_NUMOBJ (res) = 0; + free (NIS_RES_OBJECT (res)); + NIS_RES_OBJECT (res) = NULL; + NIS_RES_STATUS (allres) = NIS_RES_STATUS (res); + xdr_free ((xdrproc_t) _xdr_nis_result, (char *) res); + } + enum nis_error err = __follow_path (&tablepath, &tableptr, + ibreq, &bptr); + if (err != NIS_SUCCESS) + { + /* Prepare for the nis_freeresult call. */ + memset (res, '\0', sizeof (*res)); + + if (err == NIS_NOMEMORY) + NIS_RES_STATUS (allres) = err; + ++done; + } + } + else + ++done; + break; + case NIS_CBRESULTS: + if (cb != NULL) + { + __nis_do_callback (&bptr, &res->cookie, cb); + NIS_RES_STATUS (res) = cb->result; + + if (!(flags & ALL_RESULTS)) + ++done; + else + { + enum nis_error err + = __follow_path (&tablepath, &tableptr, ibreq, &bptr); + if (err != NIS_SUCCESS) + { + if (err == NIS_NOMEMORY) + NIS_RES_STATUS (res) = err; + ++done; + } + } + } + break; + case NIS_SYSTEMERROR: + case NIS_NOSUCHNAME: + case NIS_NOT_ME: + /* If we had first tried the old binding, do nothing, but + get a new binding */ + if (!first_try) + { + if (__nisbind_next (&bptr) != NIS_SUCCESS) + { + ++done; + break; /* No more servers to search */ + } + while (__nisbind_connect (&bptr) != NIS_SUCCESS) + { + if (__nisbind_next (&bptr) != NIS_SUCCESS) + { + ++done; + break; /* No more servers to search */ + } + } + goto again; + } + break; + default: + if (!first_try) + { + /* Try the next domainname if we don't follow a link. */ + free (ibreq->ibr_name); + ibreq->ibr_name = NULL; + if (count_links) + { + NIS_RES_STATUS (res) = NIS_LINKNAMEERROR; + ++done; + break; + } + ++name_nr; + if (names[name_nr] == NULL) + { + ++done; + break; + } + ibreq->ibr_name = strdup (names[name_nr]); + if (ibreq->ibr_name == NULL) + { + NIS_RES_STATUS (res) = NIS_NOMEMORY; + goto fail; + } + first_try = 1; /* Try old binding at first */ + goto again; + } + break; + } + first_try = 0; + + if (cb) + { + __nis_destroy_callback (cb); + ibreq->ibr_cbhost.ibr_cbhost_len = 0; + ibreq->ibr_cbhost.ibr_cbhost_val = NULL; + cb = NULL; + } + + __nisbind_destroy (&bptr); + nis_free_directory (dir); + } + + free (tablepath); + + if (names != namebuf) + nis_freenames (names); + + nis_free_request (ibreq); + + if (allres) + { + nis_freeresult (res); + return allres; + } + + return res; +} + + +nis_result * +nis_add_entry (const_nis_name name, const nis_object *obj2, unsigned int flags) +{ + nis_result *res = calloc (1, sizeof (nis_result)); + if (res == NULL) + return NULL; + + if (name == NULL) + { + NIS_RES_STATUS (res) = NIS_BADNAME; + return res; + } + + ib_request *ibreq = __create_ib_request (name, flags); + if (ibreq == NULL) + { + NIS_RES_STATUS (res) = NIS_BADNAME; + return res; + } + + nis_object obj; + memcpy (&obj, obj2, sizeof (nis_object)); + + size_t namelen = strlen (name); + char buf1[namelen + 20]; + char buf4[namelen + 20]; + + if (obj.zo_name == NULL || strlen (obj.zo_name) == 0) + obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1)); + + if (obj.zo_owner == NULL || strlen (obj.zo_owner) == 0) + obj.zo_owner = nis_local_principal (); + + if (obj.zo_group == NULL || strlen (obj.zo_group) == 0) + obj.zo_group = nis_local_group (); + + obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4)); + + ibreq->ibr_obj.ibr_obj_val = nis_clone_object (&obj, NULL); + if (ibreq->ibr_obj.ibr_obj_val == NULL) + { + nis_free_request (ibreq); + NIS_RES_STATUS (res) = NIS_NOMEMORY; + return res; + } + ibreq->ibr_obj.ibr_obj_len = 1; + + nis_error status = __do_niscall (ibreq->ibr_name, NIS_IBADD, + (xdrproc_t) _xdr_ib_request, + (caddr_t) ibreq, + (xdrproc_t) _xdr_nis_result, + (caddr_t) res, 0, NULL); + if (status != NIS_SUCCESS) + NIS_RES_STATUS (res) = status; + + nis_free_request (ibreq); + + return res; +} + +nis_result * +nis_modify_entry (const_nis_name name, const nis_object *obj2, + unsigned int flags) +{ + nis_object obj; + nis_result *res; + nis_error status; + ib_request *ibreq; + size_t namelen = strlen (name); + char buf1[namelen + 20]; + char buf4[namelen + 20]; + + res = calloc (1, sizeof (nis_result)); + if (res == NULL) + return NULL; + + ibreq = __create_ib_request (name, flags); + if (ibreq == NULL) + { + NIS_RES_STATUS (res) = NIS_BADNAME; + return res; + } + + memcpy (&obj, obj2, sizeof (nis_object)); + + if (obj.zo_name == NULL || strlen (obj.zo_name) == 0) + obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1)); + + if (obj.zo_owner == NULL || strlen (obj.zo_owner) == 0) + obj.zo_owner = nis_local_principal (); + + if (obj.zo_group == NULL || strlen (obj.zo_group) == 0) + obj.zo_group = nis_local_group (); + + obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4)); + + ibreq->ibr_obj.ibr_obj_val = nis_clone_object (&obj, NULL); + if (ibreq->ibr_obj.ibr_obj_val == NULL) + { + nis_free_request (ibreq); + NIS_RES_STATUS (res) = NIS_NOMEMORY; + return res; + } + ibreq->ibr_obj.ibr_obj_len = 1; + + status = __do_niscall (ibreq->ibr_name, NIS_IBMODIFY, + (xdrproc_t) _xdr_ib_request, + (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result, + (caddr_t) res, 0, NULL); + if (status != NIS_SUCCESS) + NIS_RES_STATUS (res) = status; + + nis_free_request (ibreq); + + return res; +} + +nis_result * +nis_remove_entry (const_nis_name name, const nis_object *obj, + unsigned int flags) +{ + nis_result *res; + ib_request *ibreq; + nis_error status; + + res = calloc (1, sizeof (nis_result)); + if (res == NULL) + return NULL; + + if (name == NULL) + { + NIS_RES_STATUS (res) = NIS_BADNAME; + return res; + } + + ibreq = __create_ib_request (name, flags); + if (ibreq == NULL) + { + NIS_RES_STATUS (res) = NIS_BADNAME; + return res; + } + + if (obj != NULL) + { + ibreq->ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL); + if (ibreq->ibr_obj.ibr_obj_val == NULL) + { + nis_free_request (ibreq); + NIS_RES_STATUS (res) = NIS_NOMEMORY; + return res; + } + ibreq->ibr_obj.ibr_obj_len = 1; + } + + if ((status = __do_niscall (ibreq->ibr_name, NIS_IBREMOVE, + (xdrproc_t) _xdr_ib_request, + (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result, + (caddr_t) res, 0, NULL)) != NIS_SUCCESS) + NIS_RES_STATUS (res) = status; + + nis_free_request (ibreq); + + return res; +} + +nis_result * +nis_first_entry (const_nis_name name) +{ + nis_result *res; + ib_request *ibreq; + nis_error status; + + res = calloc (1, sizeof (nis_result)); + if (res == NULL) + return NULL; + + if (name == NULL) + { + NIS_RES_STATUS (res) = NIS_BADNAME; + return res; + } + + ibreq = __create_ib_request (name, 0); + if (ibreq == NULL) + { + NIS_RES_STATUS (res) = NIS_BADNAME; + return res; + } + + status = __do_niscall (ibreq->ibr_name, NIS_IBFIRST, + (xdrproc_t) _xdr_ib_request, + (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result, + (caddr_t) res, 0, NULL); + + if (status != NIS_SUCCESS) + NIS_RES_STATUS (res) = status; + + nis_free_request (ibreq); + + return res; +} + +nis_result * +nis_next_entry (const_nis_name name, const netobj *cookie) +{ + nis_result *res; + ib_request *ibreq; + nis_error status; + + res = calloc (1, sizeof (nis_result)); + if (res == NULL) + return NULL; + + if (name == NULL) + { + NIS_RES_STATUS (res) = NIS_BADNAME; + return res; + } + + ibreq = __create_ib_request (name, 0); + if (ibreq == NULL) + { + NIS_RES_STATUS (res) = NIS_BADNAME; + return res; + } + + if (cookie != NULL) + { + ibreq->ibr_cookie.n_bytes = cookie->n_bytes; + ibreq->ibr_cookie.n_len = cookie->n_len; + } + + status = __do_niscall (ibreq->ibr_name, NIS_IBNEXT, + (xdrproc_t) _xdr_ib_request, + (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result, + (caddr_t) res, 0, NULL); + + if (status != NIS_SUCCESS) + NIS_RES_STATUS (res) = status; + + if (cookie != NULL) + { + /* Don't give cookie free, it is not from us */ + ibreq->ibr_cookie.n_bytes = NULL; + ibreq->ibr_cookie.n_len = 0; + } + + nis_free_request (ibreq); + + return res; +} diff --git a/src/nisplus/nis_util.c b/src/nisplus/nis_util.c new file mode 100644 index 0000000..1efd3b6 --- /dev/null +++ b/src/nisplus/nis_util.c @@ -0,0 +1,49 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "nis_intern.h" +#include "nis_xdr.h" + +fd_result * +__nis_finddirectory (directory_obj *dir, const_nis_name name) +{ + nis_error status; + fd_args fd_arg; + fd_result *fd_res; + + fd_arg.dir_name = (char *)name; + fd_arg.requester = nis_local_host(); + fd_res = calloc (1, sizeof (fd_result)); + if (fd_res == NULL) + return NULL; + + status = __do_niscall2 (dir->do_servers.do_servers_val, + dir->do_servers.do_servers_len, + NIS_FINDDIRECTORY, (xdrproc_t) _xdr_fd_args, + (caddr_t) &fd_arg, (xdrproc_t) _xdr_fd_result, + (caddr_t) fd_res, NO_AUTHINFO|USE_DGRAM, NULL); + if (status != NIS_SUCCESS) + fd_res->status = status; + + return fd_res; +} diff --git a/src/nisplus/nis_verifygroup.c b/src/nisplus/nis_verifygroup.c new file mode 100644 index 0000000..80d8976 --- /dev/null +++ b/src/nisplus/nis_verifygroup.c @@ -0,0 +1,54 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +nis_error +nis_verifygroup (const_nis_name group) +{ + if (group != NULL && group[0] != '\0') + { + size_t grouplen = strlen (group); + char buf[grouplen + 50]; + char leafbuf[grouplen + 2]; + char domainbuf[grouplen + 2]; + nis_result *res; + nis_error status; + char *cp, *cp2; + + cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1)); + cp = stpcpy (cp, ".groups_dir"); + cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); + if (cp2 != NULL && cp2[0] != '\0') + { + *cp++ = '.'; + stpcpy (cp, cp2); + } + res = nis_lookup (buf, 0); + status = NIS_RES_STATUS (res); + nis_freeresult (res); + return status; + } + else + return NIS_FAIL; +} diff --git a/src/nisplus/nis_xdr.c b/src/nisplus/nis_xdr.c new file mode 100644 index 0000000..4a7c5a8 --- /dev/null +++ b/src/nisplus/nis_xdr.c @@ -0,0 +1,466 @@ +/* Copyright (c) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include /* for "official" Solaris xdr functions */ + +/* This functions do exist without beginning "_" under Solaris 2.x, but + we have no prototypes for them. To avoid the same problems as with the + YP xdr functions, we don't make them public. */ +#include "nis_xdr.h" + +#ifndef __always_inline +#define __always_inline __attribute__((__always_inline__)) +#endif + +static bool_t +xdr_nis_attr (XDR *xdrs, nis_attr *objp) +{ + bool_t res = xdr_string (xdrs, &objp->zattr_ndx, ~0); + if (__builtin_expect (res, TRUE)) + res = xdr_bytes (xdrs, (char **) &objp->zattr_val.zattr_val_val, + &objp->zattr_val.zattr_val_len, ~0); + return res; +} + +static __always_inline bool_t +xdr_nis_name (XDR *xdrs, nis_name *objp) +{ + return xdr_string (xdrs, objp, ~0); +} + +bool_t +_xdr_nis_name (XDR *xdrs, nis_name *objp) +{ + return xdr_nis_name (xdrs, objp); +} + +static __always_inline bool_t +xdr_zotypes (XDR *xdrs, zotypes *objp) +{ + return xdr_enum (xdrs, (enum_t *) objp); +} + +static __always_inline bool_t +xdr_nstype (XDR *xdrs, nstype *objp) +{ + return xdr_enum (xdrs, (enum_t *) objp); +} + +static bool_t +xdr_oar_mask (XDR *xdrs, oar_mask *objp) +{ + bool_t res = xdr_u_int (xdrs, &objp->oa_rights); + if (__builtin_expect (res, TRUE)) + res = xdr_zotypes (xdrs, &objp->oa_otype); + return res; +} + +static bool_t +xdr_endpoint (XDR *xdrs, endpoint *objp) +{ + bool_t res = xdr_string (xdrs, &objp->uaddr, ~0); + if (__builtin_expect (res, TRUE)) + { + res = xdr_string (xdrs, &objp->family, ~0); + if (res) + res = xdr_string (xdrs, &objp->proto, ~0); + } + return res; +} + +bool_t +_xdr_nis_server (XDR *xdrs, nis_server *objp) +{ + bool_t res = xdr_nis_name (xdrs, &objp->name); + if (__builtin_expect (res, TRUE)) + { + res = xdr_array (xdrs, (void *) &objp->ep.ep_val, &objp->ep.ep_len, + ~0, sizeof (endpoint), (xdrproc_t) xdr_endpoint); + if (__builtin_expect (res, TRUE)) + { + res = xdr_u_int (xdrs, &objp->key_type); + if (__builtin_expect (res, TRUE)) + res = xdr_netobj (xdrs, &objp->pkey); + } + } + return res; +} + +bool_t +_xdr_directory_obj (XDR *xdrs, directory_obj *objp) +{ + bool_t res = xdr_nis_name (xdrs, &objp->do_name); + if (__builtin_expect (res, TRUE)) + { + res = xdr_nstype (xdrs, &objp->do_type); + if (__builtin_expect (res, TRUE)) + { + res = xdr_array (xdrs, (void *) &objp->do_servers.do_servers_val, + &objp->do_servers.do_servers_len, ~0, + sizeof (nis_server), (xdrproc_t) _xdr_nis_server); + if (__builtin_expect (res, TRUE)) + { + res = xdr_uint32_t (xdrs, &objp->do_ttl); + if (__builtin_expect (res, TRUE)) + res = xdr_array (xdrs, + (void *) &objp->do_armask.do_armask_val, + &objp->do_armask.do_armask_len, ~0, + sizeof (oar_mask), (xdrproc_t) xdr_oar_mask); + } + } + } + return res; +} + +static bool_t +xdr_entry_col (XDR *xdrs, entry_col *objp) +{ + bool_t res = xdr_u_int (xdrs, &objp->ec_flags); + if (__builtin_expect (res, TRUE)) + res = xdr_bytes (xdrs, (char **) &objp->ec_value.ec_value_val, + &objp->ec_value.ec_value_len, ~0); + return res; +} + +static bool_t +xdr_entry_obj (XDR *xdrs, entry_obj *objp) +{ + bool_t res = xdr_string (xdrs, &objp->en_type, ~0); + if (__builtin_expect (res, TRUE)) + res = xdr_array (xdrs, (void *) &objp->en_cols.en_cols_val, + &objp->en_cols.en_cols_len, ~0, + sizeof (entry_col), (xdrproc_t) xdr_entry_col); + return res; +} + +static bool_t +xdr_group_obj (XDR *xdrs, group_obj *objp) +{ + bool_t res = xdr_u_int (xdrs, &objp->gr_flags); + if (__builtin_expect (res, TRUE)) + res = xdr_array (xdrs, (void *) &objp->gr_members.gr_members_val, + &objp->gr_members.gr_members_len, ~0, + sizeof (nis_name), (xdrproc_t) _xdr_nis_name); + return res; +} + +static bool_t +xdr_link_obj (XDR *xdrs, link_obj *objp) +{ + bool_t res = xdr_zotypes (xdrs, &objp->li_rtype); + if (__builtin_expect (res, TRUE)) + { + res = xdr_array (xdrs, (void *) &objp->li_attrs.li_attrs_val, + &objp->li_attrs.li_attrs_len, ~0, + sizeof (nis_attr), (xdrproc_t) xdr_nis_attr); + if (__builtin_expect (res, TRUE)) + res = xdr_nis_name (xdrs, &objp->li_name); + } + return res; +} + +static bool_t +xdr_table_col (XDR *xdrs, table_col *objp) +{ + bool_t res = xdr_string (xdrs, &objp->tc_name, 64); + if (__builtin_expect (res, TRUE)) + { + res = xdr_u_int (xdrs, &objp->tc_flags); + if (__builtin_expect (res, TRUE)) + res = xdr_u_int (xdrs, &objp->tc_rights); + } + return res; +} + +static bool_t +xdr_table_obj (XDR *xdrs, table_obj *objp) +{ + bool_t res = xdr_string (xdrs, &objp->ta_type, 64); + if (__builtin_expect (res, TRUE)) + { + res = xdr_int (xdrs, &objp->ta_maxcol); + if (__builtin_expect (res, TRUE)) + { + res = xdr_u_char (xdrs, &objp->ta_sep); + if (__builtin_expect (res, TRUE)) + { + res = xdr_array (xdrs, (void *) &objp->ta_cols.ta_cols_val, + &objp->ta_cols.ta_cols_len, ~0, + sizeof (table_col), (xdrproc_t) xdr_table_col); + if (__builtin_expect (res, TRUE)) + res = xdr_string (xdrs, &objp->ta_path, ~0); + } + } + } + return res; +} + +static bool_t +xdr_objdata (XDR *xdrs, objdata *objp) +{ + bool_t res = xdr_zotypes (xdrs, &objp->zo_type); + if (!__builtin_expect (res, TRUE)) + return res; + switch (objp->zo_type) + { + case NIS_DIRECTORY_OBJ: + return _xdr_directory_obj (xdrs, &objp->objdata_u.di_data); + case NIS_GROUP_OBJ: + return xdr_group_obj (xdrs, &objp->objdata_u.gr_data); + case NIS_TABLE_OBJ: + return xdr_table_obj (xdrs, &objp->objdata_u.ta_data); + case NIS_ENTRY_OBJ: + return xdr_entry_obj (xdrs, &objp->objdata_u.en_data); + case NIS_LINK_OBJ: + return xdr_link_obj (xdrs, &objp->objdata_u.li_data); + case NIS_PRIVATE_OBJ: + return xdr_bytes (xdrs, &objp->objdata_u.po_data.po_data_val, + &objp->objdata_u.po_data.po_data_len, ~0); + case NIS_NO_OBJ: + case NIS_BOGUS_OBJ: + default: + return TRUE; + } +} + +static bool_t +xdr_nis_oid (XDR *xdrs, nis_oid *objp) +{ + bool_t res = xdr_uint32_t (xdrs, &objp->ctime); + if (__builtin_expect (res, TRUE)) + res = xdr_uint32_t (xdrs, &objp->mtime); + return res; +} + +bool_t +_xdr_nis_object (XDR *xdrs, nis_object *objp) +{ + bool_t res = xdr_nis_oid (xdrs, &objp->zo_oid); + if (__builtin_expect (res, TRUE)) + { + res = xdr_nis_name (xdrs, &objp->zo_name); + if (__builtin_expect (res, TRUE)) + { + res = xdr_nis_name (xdrs, &objp->zo_owner); + if (__builtin_expect (res, TRUE)) + { + res = xdr_nis_name (xdrs, &objp->zo_group); + if (__builtin_expect (res, TRUE)) + { + res = xdr_nis_name (xdrs, &objp->zo_domain); + if (__builtin_expect (res, TRUE)) + { + res = xdr_u_int (xdrs, &objp->zo_access); + if (__builtin_expect (res, TRUE)) + { + res = xdr_uint32_t (xdrs, &objp->zo_ttl); + if (__builtin_expect (res, TRUE)) + res = xdr_objdata (xdrs, &objp->zo_data); + } + } + } + } + } + } + return res; +} + +static __always_inline bool_t +xdr_nis_error (XDR *xdrs, nis_error *objp) +{ + return xdr_enum (xdrs, (enum_t *) objp); +} + +bool_t +_xdr_nis_error (XDR *xdrs, nis_error *objp) +{ + return xdr_nis_error (xdrs, objp); +} + +bool_t +_xdr_nis_result (XDR *xdrs, nis_result *objp) +{ + bool_t res = xdr_nis_error (xdrs, &objp->status); + if (__builtin_expect (res, TRUE)) + { + res = xdr_array (xdrs, (void *) &objp->objects.objects_val, + &objp->objects.objects_len, ~0, + sizeof (nis_object), (xdrproc_t) _xdr_nis_object); + if (__builtin_expect (res, TRUE)) + { + res = xdr_netobj (xdrs, &objp->cookie); + if (__builtin_expect (res, TRUE)) + { + res = xdr_uint32_t (xdrs, &objp->zticks); + if (__builtin_expect (res, TRUE)) + { + res = xdr_uint32_t (xdrs, &objp->dticks); + if (__builtin_expect (res, TRUE)) + { + res = xdr_uint32_t (xdrs, &objp->aticks); + if (__builtin_expect (res, TRUE)) + res = xdr_uint32_t (xdrs, &objp->cticks); + } + } + } + } + } + return res; +} + + +bool_t +_xdr_ns_request (XDR *xdrs, ns_request *objp) +{ + bool_t res = xdr_nis_name (xdrs, &objp->ns_name); + if (__builtin_expect (res, TRUE)) + res = xdr_array (xdrs, (void *) &objp->ns_object.ns_object_val, + &objp->ns_object.ns_object_len, 1, + sizeof (nis_object), (xdrproc_t) _xdr_nis_object); + return res; +} + +bool_t +_xdr_ib_request (XDR *xdrs, ib_request *objp) +{ + bool_t res = xdr_nis_name (xdrs, &objp->ibr_name); + if (__builtin_expect (res, TRUE)) + { + res = xdr_array (xdrs, (void *) &objp->ibr_srch.ibr_srch_val, + &objp->ibr_srch.ibr_srch_len, ~0, + sizeof (nis_attr), (xdrproc_t) xdr_nis_attr); + if (__builtin_expect (res, TRUE)) + { + res = xdr_u_int (xdrs, &objp->ibr_flags); + if (__builtin_expect (res, TRUE)) + { + res = xdr_array (xdrs, (void *) &objp->ibr_obj.ibr_obj_val, + &objp->ibr_obj.ibr_obj_len, 1, + sizeof (nis_object), + (xdrproc_t) _xdr_nis_object); + if (__builtin_expect (res, TRUE)) + { + res = xdr_array (xdrs, + (void *) &objp->ibr_cbhost.ibr_cbhost_val, + &objp->ibr_cbhost.ibr_cbhost_len, 1, + sizeof (nis_server), + (xdrproc_t) _xdr_nis_server); + if (__builtin_expect (res, TRUE)) + { + res = xdr_u_int (xdrs, &objp->ibr_bufsize); + if (__builtin_expect (res, TRUE)) + res = xdr_netobj (xdrs, &objp->ibr_cookie); + } + } + } + } + } + return res; +} + + +bool_t +_xdr_ping_args (XDR *xdrs, ping_args *objp) +{ + bool_t res = xdr_nis_name (xdrs, &objp->dir); + if (__builtin_expect (res, TRUE)) + res = xdr_uint32_t (xdrs, &objp->stamp); + return res; +} + +bool_t +_xdr_cp_result (XDR *xdrs, cp_result *objp) +{ + bool_t res = xdr_nis_error (xdrs, &objp->cp_status); + if (__builtin_expect (res, TRUE)) + { + res = xdr_uint32_t (xdrs, &objp->cp_zticks); + if (__builtin_expect (res, TRUE)) + res = xdr_uint32_t (xdrs, &objp->cp_dticks); + } + return res; +} + +bool_t +_xdr_nis_tag (XDR *xdrs, nis_tag *objp) +{ + bool_t res = xdr_u_int (xdrs, &objp->tag_type); + if (__builtin_expect (res, TRUE)) + res = xdr_string (xdrs, &objp->tag_val, ~0); + return res; +} + +bool_t +_xdr_nis_taglist (XDR *xdrs, nis_taglist *objp) +{ + return xdr_array (xdrs, (void *) &objp->tags.tags_val, + &objp->tags.tags_len, ~0, sizeof (nis_tag), + (xdrproc_t) _xdr_nis_tag); +} + +bool_t +_xdr_fd_args (XDR *xdrs, fd_args *objp) +{ + bool_t res = xdr_nis_name (xdrs, &objp->dir_name); + if (__builtin_expect (res, TRUE)) + res = xdr_nis_name (xdrs, &objp->requester); + return res; +} + +bool_t +_xdr_fd_result (XDR *xdrs, fd_result *objp) +{ + bool_t res = xdr_nis_error (xdrs, &objp->status); + if (__builtin_expect (res, TRUE)) + { + res = xdr_nis_name (xdrs, &objp->source); + if (__builtin_expect (res, TRUE)) + { + res = xdr_bytes (xdrs, (char **) &objp->dir_data.dir_data_val, + &objp->dir_data.dir_data_len, ~0); + if (__builtin_expect (res, TRUE)) + res = xdr_bytes (xdrs, (char **) &objp->signature.signature_val, + &objp->signature.signature_len, ~0); + } + } + return res; +} + +/* The following functions have prototypes in nis_callback.h. So + we make them public */ +bool_t +xdr_obj_p (XDR *xdrs, obj_p *objp) +{ + return xdr_pointer (xdrs, (char **)objp, sizeof (nis_object), + (xdrproc_t)_xdr_nis_object); +} + + +bool_t +xdr_cback_data (XDR *xdrs, cback_data *objp) +{ + return xdr_array (xdrs, (void *) &objp->entries.entries_val, + &objp->entries.entries_len, ~0, + sizeof (obj_p), (xdrproc_t) xdr_obj_p); +} diff --git a/src/nisplus/nis_xdr.h b/src/nisplus/nis_xdr.h new file mode 100644 index 0000000..cec2a7b --- /dev/null +++ b/src/nisplus/nis_xdr.h @@ -0,0 +1,39 @@ +/* Copyright (c) 1998-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1998. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifndef __NIS_XDR_H +#define __NIS_XDR_H 1 + +extern bool_t _xdr_nis_attr (XDR *, nis_attr*); +extern bool_t _xdr_nis_name (XDR *, nis_name*); +extern bool_t _xdr_nis_server (XDR *, nis_server*); +extern bool_t _xdr_directory_obj (XDR *, directory_obj*); +extern bool_t _xdr_nis_object (XDR *, nis_object*); +extern bool_t _xdr_nis_error (XDR *, nis_error*); +extern bool_t _xdr_ns_request (XDR *, ns_request*); +extern bool_t _xdr_ping_args (XDR *, ping_args*); +extern bool_t _xdr_cp_result (XDR *, cp_result*); +extern bool_t _xdr_nis_tag (XDR *, nis_tag*); +extern bool_t _xdr_nis_taglist (XDR *, nis_taglist*); +extern bool_t _xdr_fd_args (XDR *, fd_args*); +extern bool_t _xdr_fd_result (XDR *, fd_result*); + +extern bool_t _xdr_ib_request (XDR *, ib_request*); +extern bool_t _xdr_nis_result (XDR *, nis_result*); + +#endif diff --git a/src/rpcsvc/nis.h b/src/rpcsvc/nis.h new file mode 100644 index 0000000..ee9e177 --- /dev/null +++ b/src/rpcsvc/nis.h @@ -0,0 +1,619 @@ +/* + * Copyright (c) 2010, Oracle America, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of the "Oracle America, Inc." nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT HOLDER OR CONTRIBUTORS 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. + */ + +#ifndef _RPCSVC_NIS_H +#define _RPCSVC_NIS_H 1 + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * nis.h + * + * This file is the main include file for NIS clients. It contains + * both the client library function defines and the various data + * structures used by the NIS service. It includes the file nis_tags.h + * which defines the tag values. This allows the tags to change without + * having to change the nis.x file. + * + * NOTE : THIS FILE IS NOT GENERATED WITH RPCGEN ! SO YOU HAVE TO + * ADD ALL THE CHANGES ON nis_*.x FILES HERE AGAIN ! + * + * I have removed all the Solaris internal structs and variables, + * because they are not supported, Sun changed them between various + * releases and they shouldn't be used in user programs. + * + */ + + +#ifndef __nis_object_h +#define __nis_object_h + +#define NIS_MAXSTRINGLEN 255 +#define NIS_MAXNAMELEN 1024 +#define NIS_MAXATTRNAME 32 +#define NIS_MAXATTRVAL 2048 +#define NIS_MAXCOLUMNS 64 +#define NIS_MAXATTR 16 +#define NIS_MAXPATH 1024 +#define NIS_MAXREPLICAS 128 +#define NIS_MAXLINKS 16 +#define NIS_PK_NONE 0 +#define NIS_PK_DH 1 +#define NIS_PK_RSA 2 +#define NIS_PK_KERB 3 +#define NIS_PK_DHEXT 4 + +struct nis_attr { + char *zattr_ndx; + struct { + u_int zattr_val_len; + char *zattr_val_val; + } zattr_val; +}; +typedef struct nis_attr nis_attr; + +typedef char *nis_name; + +enum zotypes { + BOGUS_OBJ = 0, + NO_OBJ = 1, + DIRECTORY_OBJ = 2, + GROUP_OBJ = 3, + TABLE_OBJ = 4, + ENTRY_OBJ = 5, + LINK_OBJ = 6, + PRIVATE_OBJ = 7, + NIS_BOGUS_OBJ = 0, + NIS_NO_OBJ = 1, + NIS_DIRECTORY_OBJ = 2, + NIS_GROUP_OBJ = 3, + NIS_TABLE_OBJ = 4, + NIS_ENTRY_OBJ = 5, + NIS_LINK_OBJ = 6, + NIS_PRIVATE_OBJ = 7 +}; +typedef enum zotypes zotypes; + +enum nstype { + UNKNOWN = 0, + NIS = 1, + SUNYP = 2, + IVY = 3, + DNS = 4, + X500 = 5, + DNANS = 6, + XCHS = 7, + CDS = 8, +}; +typedef enum nstype nstype; + +struct oar_mask { + uint32_t oa_rights; + zotypes oa_otype; +}; +typedef struct oar_mask oar_mask; + +struct endpoint { + char *uaddr; + char *family; + char *proto; +}; +typedef struct endpoint endpoint; + +struct nis_server { + nis_name name; + struct { + u_int ep_len; + endpoint *ep_val; + } ep; + uint32_t key_type; + netobj pkey; +}; +typedef struct nis_server nis_server; + +struct directory_obj { + nis_name do_name; + nstype do_type; + struct { + u_int do_servers_len; + nis_server *do_servers_val; + } do_servers; + uint32_t do_ttl; + struct { + u_int do_armask_len; + oar_mask *do_armask_val; + } do_armask; +}; +typedef struct directory_obj directory_obj; + +#define EN_BINARY 1 +#define EN_CRYPT 2 +#define EN_XDR 4 +#define EN_MODIFIED 8 +#define EN_ASN1 64 + +struct entry_col { + uint32_t ec_flags; + struct { + u_int ec_value_len; + char *ec_value_val; + } ec_value; +}; +typedef struct entry_col entry_col; + +struct entry_obj { + char *en_type; + struct { + u_int en_cols_len; + entry_col *en_cols_val; + } en_cols; +}; +typedef struct entry_obj entry_obj; + +struct group_obj { + uint32_t gr_flags; + struct { + u_int gr_members_len; + nis_name *gr_members_val; + } gr_members; +}; +typedef struct group_obj group_obj; + +struct link_obj { + zotypes li_rtype; + struct { + u_int li_attrs_len; + nis_attr *li_attrs_val; + } li_attrs; + nis_name li_name; +}; +typedef struct link_obj link_obj; + +#define TA_BINARY 1 +#define TA_CRYPT 2 +#define TA_XDR 4 +#define TA_SEARCHABLE 8 +#define TA_CASE 16 +#define TA_MODIFIED 32 +#define TA_ASN1 64 + +struct table_col { + char *tc_name; + uint32_t tc_flags; + uint32_t tc_rights; +}; +typedef struct table_col table_col; + +struct table_obj { + char *ta_type; + int ta_maxcol; + u_char ta_sep; + struct { + u_int ta_cols_len; + table_col *ta_cols_val; + } ta_cols; + char *ta_path; +}; +typedef struct table_obj table_obj; + +struct objdata { + zotypes zo_type; + union { + struct directory_obj di_data; + struct group_obj gr_data; + struct table_obj ta_data; + struct entry_obj en_data; + struct link_obj li_data; + struct { + u_int po_data_len; + char *po_data_val; + } po_data; + } objdata_u; +}; +typedef struct objdata objdata; + +struct nis_oid { + uint32_t ctime; + uint32_t mtime; +}; +typedef struct nis_oid nis_oid; + +struct nis_object { + nis_oid zo_oid; + nis_name zo_name; + nis_name zo_owner; + nis_name zo_group; + nis_name zo_domain; + uint32_t zo_access; + uint32_t zo_ttl; + objdata zo_data; +}; +typedef struct nis_object nis_object; + +#endif /* if __nis_object_h */ + +enum nis_error { + NIS_SUCCESS = 0, + NIS_S_SUCCESS = 1, + NIS_NOTFOUND = 2, + NIS_S_NOTFOUND = 3, + NIS_CACHEEXPIRED = 4, + NIS_NAMEUNREACHABLE = 5, + NIS_UNKNOWNOBJ = 6, + NIS_TRYAGAIN = 7, + NIS_SYSTEMERROR = 8, + NIS_CHAINBROKEN = 9, + NIS_PERMISSION = 10, + NIS_NOTOWNER = 11, + NIS_NOT_ME = 12, + NIS_NOMEMORY = 13, + NIS_NAMEEXISTS = 14, + NIS_NOTMASTER = 15, + NIS_INVALIDOBJ = 16, + NIS_BADNAME = 17, + NIS_NOCALLBACK = 18, + NIS_CBRESULTS = 19, + NIS_NOSUCHNAME = 20, + NIS_NOTUNIQUE = 21, + NIS_IBMODERROR = 22, + NIS_NOSUCHTABLE = 23, + NIS_TYPEMISMATCH = 24, + NIS_LINKNAMEERROR = 25, + NIS_PARTIAL = 26, + NIS_TOOMANYATTRS = 27, + NIS_RPCERROR = 28, + NIS_BADATTRIBUTE = 29, + NIS_NOTSEARCHABLE = 30, + NIS_CBERROR = 31, + NIS_FOREIGNNS = 32, + NIS_BADOBJECT = 33, + NIS_NOTSAMEOBJ = 34, + NIS_MODFAIL = 35, + NIS_BADREQUEST = 36, + NIS_NOTEMPTY = 37, + NIS_COLDSTART_ERR = 38, + NIS_RESYNC = 39, + NIS_FAIL = 40, + NIS_UNAVAIL = 41, + NIS_RES2BIG = 42, + NIS_SRVAUTH = 43, + NIS_CLNTAUTH = 44, + NIS_NOFILESPACE = 45, + NIS_NOPROC = 46, + NIS_DUMPLATER = 47, +}; +typedef enum nis_error nis_error; + +struct nis_result { + nis_error status; + struct { + u_int objects_len; + nis_object *objects_val; + } objects; + netobj cookie; + uint32_t zticks; + uint32_t dticks; + uint32_t aticks; + uint32_t cticks; +}; +typedef struct nis_result nis_result; + +struct ns_request { + nis_name ns_name; + struct { + u_int ns_object_len; + nis_object *ns_object_val; + } ns_object; +}; +typedef struct ns_request ns_request; + +struct ib_request { + nis_name ibr_name; + struct { + u_int ibr_srch_len; + nis_attr *ibr_srch_val; + } ibr_srch; + uint32_t ibr_flags; + struct { + u_int ibr_obj_len; + nis_object *ibr_obj_val; + } ibr_obj; + struct { + u_int ibr_cbhost_len; + nis_server *ibr_cbhost_val; + } ibr_cbhost; + u_int ibr_bufsize; + netobj ibr_cookie; +}; +typedef struct ib_request ib_request; + +struct ping_args { + nis_name dir; + uint32_t stamp; +}; +typedef struct ping_args ping_args; + +enum log_entry_t { + LOG_NOP = 0, + ADD_NAME = 1, + REM_NAME = 2, + MOD_NAME_OLD = 3, + MOD_NAME_NEW = 4, + ADD_IBASE = 5, + REM_IBASE = 6, + MOD_IBASE = 7, + UPD_STAMP = 8, +}; +typedef enum log_entry_t log_entry_t; + +struct log_entry { + uint32_t le_time; + log_entry_t le_type; + nis_name le_princp; + nis_name le_name; + struct { + u_int le_attrs_len; + nis_attr *le_attrs_val; + } le_attrs; + nis_object le_object; +}; +typedef struct log_entry log_entry; + +struct log_result { + nis_error lr_status; + netobj lr_cookie; + struct { + u_int lr_entries_len; + log_entry *lr_entries_val; + } lr_entries; +}; +typedef struct log_result log_result; + +struct cp_result { + nis_error cp_status; + uint32_t cp_zticks; + uint32_t cp_dticks; +}; +typedef struct cp_result cp_result; + +struct nis_tag { + uint32_t tag_type; + char *tag_val; +}; +typedef struct nis_tag nis_tag; + +struct nis_taglist { + struct { + u_int tags_len; + nis_tag *tags_val; + } tags; +}; +typedef struct nis_taglist nis_taglist; + +struct dump_args { + nis_name da_dir; + uint32_t da_time; + struct { + u_int da_cbhost_len; + nis_server *da_cbhost_val; + } da_cbhost; +}; +typedef struct dump_args dump_args; + +struct fd_args { + nis_name dir_name; + nis_name requester; +}; +typedef struct fd_args fd_args; + +struct fd_result { + nis_error status; + nis_name source; + struct { + u_int dir_data_len; + char *dir_data_val; + } dir_data; + struct { + u_int signature_len; + char *signature_val; + } signature; +}; +typedef struct fd_result fd_result; + +/* Generic client creating flags */ +#define ZMH_VC 1 +#define ZMH_DG 2 +#define ZMH_AUTH 4 + +/* Testing Access rights for objects */ + +#define NIS_READ_ACC 1 +#define NIS_MODIFY_ACC 2 +#define NIS_CREATE_ACC 4 +#define NIS_DESTROY_ACC 8 +/* Test macros. a == access rights, m == desired rights. */ +#define NIS_WORLD(a, m) (((a) & (m)) != 0) +#define NIS_GROUP(a, m) (((a) & ((m) << 8)) != 0) +#define NIS_OWNER(a, m) (((a) & ((m) << 16)) != 0) +#define NIS_NOBODY(a, m) (((a) & ((m) << 24)) != 0) +/* + * EOL Alert - The following non-prefixed test macros are + * here for backward compatibility, and will be not be present + * in future releases - use the NIS_*() macros above. + */ +#define WORLD(a, m) (((a) & (m)) != 0) +#define GROUP(a, m) (((a) & ((m) << 8)) != 0) +#define OWNER(a, m) (((a) & ((m) << 16)) != 0) +#define NOBODY(a, m) (((a) & ((m) << 24)) != 0) + +#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype) +#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights) +#define WORLD_DEFAULT (NIS_READ_ACC) +#define GROUP_DEFAULT (NIS_READ_ACC << 8) +#define OWNER_DEFAULT ((NIS_READ_ACC + NIS_MODIFY_ACC + NIS_CREATE_ACC +\ + NIS_DESTROY_ACC) << 16) +#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT) + +/* Result manipulation defines ... */ +#define NIS_RES_NUMOBJ(x) ((x)->objects.objects_len) +#define NIS_RES_OBJECT(x) ((x)->objects.objects_val) +#define NIS_RES_COOKIE(x) ((x)->cookie) +#define NIS_RES_STATUS(x) ((x)->status) + +/* These defines make getting at the variant part of the object easier. */ +#define TA_data zo_data.objdata_u.ta_data +#define EN_data zo_data.objdata_u.en_data +#define DI_data zo_data.objdata_u.di_data +#define LI_data zo_data.objdata_u.li_data +#define GR_data zo_data.objdata_u.gr_data + +#define __type_of(o) ((o)->zo_data.zo_type) + +/* Declarations for the internal subroutines in nislib.c */ +enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME}; +typedef enum name_pos name_pos; + +/* + * Defines for getting at column data in entry objects. Because RPCGEN + * generates some rather wordy structures, we create some defines that + * collapse the needed keystrokes to access a particular value using + * these definitions they take an nis_object *, and an int and return + * a u_char * for Value, and an int for length. + */ +#define ENTRY_VAL(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val +#define ENTRY_LEN(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len + + +/* Prototypes, and extern declarations for the NIS library functions. */ +#include +#endif + +/* + * nis_3.h + * + * This file contains definitions that are only of interest to the actual + * service daemon and client stubs. Normal users of NIS will not include + * this file. + * + * NOTE : This include file is automatically created by a combination + * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead + * and then remake this file. + */ +#ifndef __nis_3_h +#define __nis_3_h + +#define NIS_PROG 100300 +#define NIS_VERSION 3 + +#define NIS_LOOKUP 1 +extern nis_result * nis_lookup_3 (ns_request *, CLIENT *); +extern nis_result * nis_lookup_3_svc (ns_request *, struct svc_req *); +#define NIS_ADD 2 +extern nis_result * nis_add_3 (ns_request *, CLIENT *); +extern nis_result * nis_add_3_svc (ns_request *, struct svc_req *); +#define NIS_MODIFY 3 +extern nis_result * nis_modify_3 (ns_request *, CLIENT *); +extern nis_result * nis_modify_3_svc (ns_request *, struct svc_req *); +#define NIS_REMOVE 4 +extern nis_result * nis_remove_3 (ns_request *, CLIENT *); +extern nis_result * nis_remove_3_svc (ns_request *, struct svc_req *); +#define NIS_IBLIST 5 +extern nis_result * nis_iblist_3 (ib_request *, CLIENT *); +extern nis_result * nis_iblist_3_svc (ib_request *, struct svc_req *); +#define NIS_IBADD 6 +extern nis_result * nis_ibadd_3 (ib_request *, CLIENT *); +extern nis_result * nis_ibadd_3_svc (ib_request *, struct svc_req *); +#define NIS_IBMODIFY 7 +extern nis_result * nis_ibmodify_3 (ib_request *, CLIENT *); +extern nis_result * nis_ibmodify_3_svc (ib_request *, struct svc_req *) + ; +#define NIS_IBREMOVE 8 +extern nis_result * nis_ibremove_3 (ib_request *, CLIENT *); +extern nis_result * nis_ibremove_3_svc (ib_request *, struct svc_req *) + ; +#define NIS_IBFIRST 9 +extern nis_result * nis_ibfirst_3 (ib_request *, CLIENT *); +extern nis_result * nis_ibfirst_3_svc (ib_request *, struct svc_req *) + ; +#define NIS_IBNEXT 10 +extern nis_result * nis_ibnext_3 (ib_request *, CLIENT *); +extern nis_result * nis_ibnext_3_svc (ib_request *, struct svc_req *); +#define NIS_FINDDIRECTORY 12 +extern fd_result * nis_finddirectory_3 (fd_args *, CLIENT *); +extern fd_result * nis_finddirectory_3_svc (fd_args *, + struct svc_req *); +#define NIS_STATUS 14 +extern nis_taglist * nis_status_3 (nis_taglist *, CLIENT *); +extern nis_taglist * nis_status_3_svc (nis_taglist *, struct svc_req *) + ; +#define NIS_DUMPLOG 15 +extern log_result * nis_dumplog_3 (dump_args *, CLIENT *); +extern log_result * nis_dumplog_3_svc (dump_args *, struct svc_req *); +#define NIS_DUMP 16 +extern log_result * nis_dump_3 (dump_args *, CLIENT *); +extern log_result * nis_dump_3_svc (dump_args *, struct svc_req *); +#define NIS_CALLBACK 17 +extern bool_t * nis_callback_3 (netobj *, CLIENT *); +extern bool_t * nis_callback_3_svc (netobj *, struct svc_req *); +#define NIS_CPTIME 18 +extern uint32_t * nis_cptime_3 (nis_name *, CLIENT *); +extern uint32_t * nis_cptime_3_svc (nis_name *, struct svc_req *); +#define NIS_CHECKPOINT 19 +extern cp_result * nis_checkpoint_3 (nis_name *, CLIENT *); +extern cp_result * nis_checkpoint_3_svc (nis_name *, struct svc_req *) + ; +#define NIS_PING 20 +extern void * nis_ping_3 (ping_args *, CLIENT *); +extern void * nis_ping_3_svc (ping_args *, struct svc_req *); +#define NIS_SERVSTATE 21 +extern nis_taglist * nis_servstate_3 (nis_taglist *, CLIENT *); +extern nis_taglist * nis_servstate_3_svc (nis_taglist *, + struct svc_req *); +#define NIS_MKDIR 22 +extern nis_error * nis_mkdir_3 (nis_name *, CLIENT *); +extern nis_error * nis_mkdir_3_svc (nis_name *, struct svc_req *); +#define NIS_RMDIR 23 +extern nis_error * nis_rmdir_3 (nis_name *, CLIENT *); +extern nis_error * nis_rmdir_3_svc (nis_name *, struct svc_req *); +#define NIS_UPDKEYS 24 +extern nis_error * nis_updkeys_3 (nis_name *, CLIENT *); +extern nis_error * nis_updkeys_3_svc (nis_name *, struct svc_req *); + +#ifdef __cplusplus +} +#endif + +#endif /* ! _RPCSVC_NIS_H */ diff --git a/src/rpcsvc/nis.x b/src/rpcsvc/nis.x new file mode 100644 index 0000000..e318af2 --- /dev/null +++ b/src/rpcsvc/nis.x @@ -0,0 +1,474 @@ +%/* +% * Copyright (c) 2010, Oracle America, Inc. +% * +% * Redistribution and use in source and binary forms, with or without +% * modification, are permitted provided that the following conditions are +% * met: +% * +% * * Redistributions of source code must retain the above copyright +% * notice, this list of conditions and the following disclaimer. +% * * 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. +% * * Neither the name of the "Oracle America, Inc." nor the names of its +% * contributors may be used to endorse or promote products derived +% * from this software without specific prior written permission. +% * +% * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +% * "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 +% * COPYRIGHT HOLDER OR CONTRIBUTORS 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. +% */ + +#ifdef RPC_HDR +%/* +% * nis.h +% * +% * This file is the main include file for NIS clients. It contains +% * both the client library function defines and the various data +% * structures used by the NIS service. It includes the file nis_tags.h +% * which defines the tag values. This allows the tags to change without +% * having to change the nis.x file. +% * +% * NOTE : DO NOT EDIT THIS FILE! It is automatically generated when +% * rpcgen is run on the nis.x file. Note that there is a +% * simple sed script to remove some unneeded lines. (See the +% * Makefile target nis.h) +% * +% */ +%#include +#endif + +/* This gets stuffed into the source files. */ +#if RPC_HDR +%#include +#endif + +/* Include the RPC Language description of NIS objects */ +#include "nis_object.x" + +/* Errors that can be returned by the service */ +enum nis_error { + NIS_SUCCESS = 0, /* A-ok, let's rock n roll */ + NIS_S_SUCCESS = 1, /* Name found (maybe) */ + NIS_NOTFOUND = 2, /* Name definitely not found */ + NIS_S_NOTFOUND = 3, /* Name maybe not found */ + NIS_CACHEEXPIRED = 4, /* Name exists but cache out of date */ + NIS_NAMEUNREACHABLE = 5, /* Can't get there from here */ + NIS_UNKNOWNOBJ = 6, /* Object type is bogus */ + NIS_TRYAGAIN = 7, /* I'm busy, call back */ + NIS_SYSTEMERROR = 8, /* Generic system error */ + NIS_CHAINBROKEN = 9, /* First/Next warning */ + NIS_PERMISSION = 10, /* Not enough permission to access */ + NIS_NOTOWNER = 11, /* You don't own it, sorry */ + NIS_NOT_ME = 12, /* I don't serve this name */ + NIS_NOMEMORY = 13, /* Outta VM! Help! */ + NIS_NAMEEXISTS = 14, /* Can't create over another name */ + NIS_NOTMASTER = 15, /* I'm justa secondaray, don't ask me */ + NIS_INVALIDOBJ = 16, /* Object is broken somehow */ + NIS_BADNAME = 17, /* Unparsable name */ + NIS_NOCALLBACK = 18, /* Couldn't talk to call back proc */ + NIS_CBRESULTS = 19, /* Results being called back to you */ + NIS_NOSUCHNAME = 20, /* Name unknown */ + NIS_NOTUNIQUE = 21, /* Value is not uniques (entry) */ + NIS_IBMODERROR = 22, /* Inf. Base. Modify error. */ + NIS_NOSUCHTABLE = 23, /* Name for table was wrong */ + NIS_TYPEMISMATCH = 24, /* Entry and table type mismatch */ + NIS_LINKNAMEERROR = 25, /* Link points to bogus name */ + NIS_PARTIAL = 26, /* Partial success, found table */ + NIS_TOOMANYATTRS = 27, /* Too many attributes */ + NIS_RPCERROR = 28, /* RPC error encountered */ + NIS_BADATTRIBUTE = 29, /* Bad or invalid attribute */ + NIS_NOTSEARCHABLE = 30, /* Non-searchable object searched */ + NIS_CBERROR = 31, /* Error during callback (svc crash) */ + NIS_FOREIGNNS = 32, /* Foreign Namespace */ + NIS_BADOBJECT = 33, /* Malformed object structure */ + NIS_NOTSAMEOBJ = 34, /* Object swapped during deletion */ + NIS_MODFAIL = 35, /* Failure during a Modify. */ + NIS_BADREQUEST = 36, /* Illegal query for table */ + NIS_NOTEMPTY = 37, /* Attempt to remove a non-empty tbl */ + NIS_COLDSTART_ERR = 38, /* Error accesing the cold start file */ + NIS_RESYNC = 39, /* Transaction log too far out of date */ + NIS_FAIL = 40, /* NIS operation failed. */ + NIS_UNAVAIL = 41, /* NIS+ service is unavailable (client) */ + NIS_RES2BIG = 42, /* NIS+ result too big for datagram */ + NIS_SRVAUTH = 43, /* NIS+ server wasn't authenticated. */ + NIS_CLNTAUTH = 44, /* NIS+ Client wasn't authenticated. */ + NIS_NOFILESPACE = 45, /* NIS+ server ran out of disk space */ + NIS_NOPROC = 46, /* NIS+ server couldn't create new proc */ + NIS_DUMPLATER = 47 /* NIS+ server already has dump child */ +}; + + +/* + * Structure definitions for the parameters and results of the actual + * NIS RPC calls. + * + * This is the standard result (in the protocol) of most of the nis + * requests. + */ + +struct nis_result { + nis_error status; /* Status of the response */ + nis_object objects<>; /* objects found */ + netobj cookie; /* Cookie Data */ + uint32_t zticks; /* server ticks */ + uint32_t dticks; /* DBM ticks. */ + uint32_t aticks; /* Cache (accel) ticks */ + uint32_t cticks; /* Client ticks */ +}; + +/* + * A Name Service request + * This request is used to access the name space, ns_name is the name + * of the object within the namespace and the object is it's value, for + * add/modify, a copy of the original for remove. + */ + +struct ns_request { + nis_name ns_name; /* Name in the NIS name space */ + nis_object ns_object<1>; /* Optional Object (add/remove) */ +}; + +/* + * An information base request + * This request includes the NIS name of the table we wish to search, the + * search criteria in the form of attribute/value pairs and an optional + * callback program number. If the callback program number is provided + * the server will send back objects one at a time, otherwise it will + * return them all in the response. + */ + +struct ib_request { + nis_name ibr_name; /* The name of the Table */ + nis_attr ibr_srch<>; /* The search critereia */ + uint32_t ibr_flags; /* Optional flags */ + nis_object ibr_obj<1>; /* optional object (add/modify) */ + nis_server ibr_cbhost<1>; /* Optional callback info */ + u_int ibr_bufsize; /* Optional first/next bufsize */ + netobj ibr_cookie; /* The first/next cookie */ +}; + +/* + * This argument to the PING call notifies the replicas that something in + * a directory has changed and this is it's timestamp. The replica will use + * the timestamp to determine if its resync operation was successful. + */ +struct ping_args { + nis_name dir; /* Directory that had the change */ + uint32_t stamp; /* timestamp of the transaction */ +}; + +/* + * These are the type of entries that are stored in the transaction log, + * note that modifications will appear as two entries, for names, they have + * a "OLD" entry followed by a "NEW" entry. For entries in tables, there + * is a remove followed by an add. It is done this way so that we can read + * the log backwards to back out transactions and forwards to propogate + * updated. + */ +enum log_entry_t { + LOG_NOP = 0, + ADD_NAME = 1, /* Name Added to name space */ + REM_NAME = 2, /* Name removed from name space */ + MOD_NAME_OLD = 3, /* Name was modified in the name space */ + MOD_NAME_NEW = 4, /* Name was modified in the name space */ + ADD_IBASE = 5, /* Entry added to information base */ + REM_IBASE = 6, /* Entry removed from information base */ + MOD_IBASE = 7, /* Entry was modified in information base */ + UPD_STAMP = 8 /* Update timestamp (used as fenceposts) */ +}; + +/* + * This result is returned from the name service when it is requested to + * dump logged entries from its transaction log. Information base updates + * will have the name of the information base in the le_name field and + * a canonical set of attribute/value pairs to fully specify the entry's + * 'name'. + */ +struct log_entry { + uint32_t le_time; /* Time in seconds */ + log_entry_t le_type; /* Type of log entry */ + nis_name le_princp; /* Principal making the change */ + nis_name le_name; /* Name of table/dir involved */ + nis_attr le_attrs<>; /* List of AV pairs. */ + nis_object le_object; /* Actual object value */ +}; + +struct log_result { + nis_error lr_status; /* The status itself */ + netobj lr_cookie; /* Used by the dump callback */ + log_entry lr_entries<>; /* zero or more entries */ +}; + +struct cp_result { + nis_error cp_status; /* Status of the checkpoint */ + uint32_t cp_zticks; /* Service 'ticks' */ + uint32_t cp_dticks; /* Database 'ticks' */ +}; + +/* + * This structure defines a generic NIS tag list. The taglist contains + * zero or tags, each of which is a type and a value. (u_int). + * These are used to report statistics (see tag definitions below) + * and to set or reset state variables. + */ +struct nis_tag { + uint32_t tag_type; /* Statistic tag (may vary) */ + string tag_val<>; /* Statistic value may also vary */ +}; + +struct nis_taglist { + nis_tag tags<>; /* List of tags */ +}; + +struct dump_args { + nis_name da_dir; /* Directory to dump */ + uint32_t da_time; /* From this timestamp */ + nis_server da_cbhost<1>; /* Callback to use. */ +}; + +struct fd_args { + nis_name dir_name; /* The directory we're looking for */ + nis_name requester; /* Host principal name for signature */ +}; + +struct fd_result { + nis_error status; /* Status returned by function */ + nis_name source; /* Source of this answer */ + opaque dir_data<>; /* Directory Data (XDR'ed) */ + opaque signature<>; /* Signature of the source */ +}; + +%/* +% * Structures used for server binding. +% */ +struct nis_bound_endpoint { + endpoint ep; + int generation; + int rank; + uint32_t flags; + int hostnum; + int epnum; + nis_name uaddr; + endpoint cbep; +}; +typedef struct nis_bound_endpoint nis_bound_endpoint; + +struct nis_bound_directory { + int generation; + int min_rank; /* minimum rank of bound endpoints */ + int optimal_rank; /* best possible rank of all endpoints */ + directory_obj dobj; + nis_bound_endpoint BEP<>; +}; +typedef struct nis_bound_directory nis_bound_directory; +%#define bep_len BEP.BEP_len +%#define bep_val BEP.BEP_val + +struct nis_active_endpoint { + endpoint ep; + nis_name hostname; + int rank; + int uaddr_generation; + nis_name uaddr; + int cbep_generation; + endpoint cbep; +}; +typedef struct nis_active_endpoint nis_active_endpoint; + +%/* defines for nis_bound_endpoint.flags */ +%#define NIS_BOUND 0x1 +%#define NIS_TRANSIENT_ERRORS 0x2 + +program NIS_PROG { + + /* RPC Language description of the NIS+ protocol */ + version NIS_VERSION { + /* The name service functions */ + nis_result NIS_LOOKUP(ns_request) = 1; + nis_result NIS_ADD(ns_request) = 2; + nis_result NIS_MODIFY(ns_request) = 3; + nis_result NIS_REMOVE(ns_request) = 4; + + /* The information base functions */ + nis_result NIS_IBLIST(ib_request) = 5; + nis_result NIS_IBADD(ib_request) = 6; + nis_result NIS_IBMODIFY(ib_request) = 7; + nis_result NIS_IBREMOVE(ib_request) = 8; + nis_result NIS_IBFIRST(ib_request) = 9; + nis_result NIS_IBNEXT(ib_request) = 10; + + /* NIS Administrative functions */ + fd_result NIS_FINDDIRECTORY(fd_args) = 12; + + /* If fetch and optionally reset statistics */ + nis_taglist NIS_STATUS(nis_taglist) = 14; + + /* Dump changes to directory since time in da_time */ + log_result NIS_DUMPLOG(dump_args) = 15; + + /* Dump contents of directory named */ + log_result NIS_DUMP(dump_args) = 16; + + /* Check status of callback thread */ + bool NIS_CALLBACK(netobj) = 17; + + /* Return last update time for named dir */ + uint32_t NIS_CPTIME(nis_name) = 18; + + /* Checkpoint directory or table named */ + cp_result NIS_CHECKPOINT(nis_name) = 19; + + /* Send 'status changed' ping to replicates */ + void NIS_PING(ping_args) = 20; + + /* Modify server behaviour (such as debugging) */ + nis_taglist NIS_SERVSTATE(nis_taglist) = 21; + + /* Create a Directory */ + nis_error NIS_MKDIR(nis_name) = 22; + + /* Remove a Directory */ + nis_error NIS_RMDIR(nis_name) = 23; + + /* Update public keys of a directory object */ + nis_error NIS_UPDKEYS(nis_name) = 24; + } = 3; +} = 100300; + +/* + * Included below are the defines that become part of nis.h, + * they are technically not part of the protocol, but do define + * key aspects of the implementation and are therefore useful + * in building a conforming server or client. + */ +#if RPC_HDR +%/* +% * Generic "hash" datastructures, used by all types of hashed data. +% */ +%struct nis_hash_data { +% nis_name name; /* NIS name of hashed item */ +% int keychain; /* It's hash key (for pop) */ +% struct nis_hash_data *next; /* Hash collision pointer */ +% struct nis_hash_data *prv_item; /* A serial, doubly linked list */ +% struct nis_hash_data *nxt_item; /* of items in the hash table */ +%}; +%typedef struct nis_hash_data NIS_HASH_ITEM; +% +%struct nis_hash_table { +% NIS_HASH_ITEM *keys[64]; /* A hash table of items */ +% NIS_HASH_ITEM *first; /* The first "item" in serial list */ +%}; +%typedef struct nis_hash_table NIS_HASH_TABLE; +% +%/* Structure for storing dynamically allocated static data */ +%struct nis_sdata { +% void *buf; /* Memory allocation pointer */ +% u_int size; /* Buffer size */ +%}; +% +%/* Generic client creating flags */ +%#define ZMH_VC 1 +%#define ZMH_DG 2 +%#define ZMH_AUTH 4 +% +%/* Testing Access rights for objects */ +% +%#define NIS_READ_ACC 1 +%#define NIS_MODIFY_ACC 2 +%#define NIS_CREATE_ACC 4 +%#define NIS_DESTROY_ACC 8 +%/* Test macros. a == access rights, m == desired rights. */ +%#define NIS_WORLD(a, m) (((a) & (m)) != 0) +%#define NIS_GROUP(a, m) (((a) & ((m) << 8)) != 0) +%#define NIS_OWNER(a, m) (((a) & ((m) << 16)) != 0) +%#define NIS_NOBODY(a, m) (((a) & ((m) << 24)) != 0) +%/* +% * EOL Alert - The following non-prefixed test macros are +% * here for backward compatability, and will be not be present +% * in future releases - use the NIS_*() macros above. +% */ +%#define WORLD(a, m) (((a) & (m)) != 0) +%#define GROUP(a, m) (((a) & ((m) << 8)) != 0) +%#define OWNER(a, m) (((a) & ((m) << 16)) != 0) +%#define NOBODY(a, m) (((a) & ((m) << 24)) != 0) +% +%#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype) +%#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights) +%#define WORLD_DEFAULT (NIS_READ_ACC) +%#define GROUP_DEFAULT (NIS_READ_ACC << 8) +%#define OWNER_DEFAULT ((NIS_READ_ACC +\ + NIS_MODIFY_ACC +\ + NIS_CREATE_ACC +\ + NIS_DESTROY_ACC) << 16) +%#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT) +% +%/* Result manipulation defines ... */ +%#define NIS_RES_NUMOBJ(x) ((x)->objects.objects_len) +%#define NIS_RES_OBJECT(x) ((x)->objects.objects_val) +%#define NIS_RES_COOKIE(x) ((x)->cookie) +%#define NIS_RES_STATUS(x) ((x)->status) +% +%/* These defines make getting at the variant part of the object easier. */ +%#define TA_data zo_data.objdata_u.ta_data +%#define EN_data zo_data.objdata_u.en_data +%#define DI_data zo_data.objdata_u.di_data +%#define LI_data zo_data.objdata_u.li_data +%#define GR_data zo_data.objdata_u.gr_data +% +%#define __type_of(o) ((o)->zo_data.zo_type) +% +%/* Declarations for the internal subroutines in nislib.c */ +%enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME}; +%typedef enum name_pos name_pos; +% +%/* +% * Defines for getting at column data in entry objects. Because RPCGEN +% * generates some rather wordy structures, we create some defines that +% * collapse the needed keystrokes to access a particular value using +% * these definitions they take an nis_object *, and an int and return +% * a u_char * for Value, and an int for length. +% */ +%#define ENTRY_VAL(obj, col) \ +% (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val +%#define ENTRY_LEN(obj, col) \ +% (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len +% +% +% +%#ifdef __cplusplus +%} +%#endif +% +%/* Prototypes, and extern declarations for the NIS library functions. */ +%#include +%#endif /* __NIS_RPCGEN_H */ +%/* EDIT_START */ +% +%/* +% * nis_3.h +% * +% * This file contains definitions that are only of interest to the actual +% * service daemon and client stubs. Normal users of NIS will not include +% * this file. +% * +% * NOTE : This include file is automatically created by a combination +% * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead +% * and then remake this file. +% */ +%#ifndef __nis_3_h +%#define __nis_3_h +%#ifdef __cplusplus +%extern "C" { +%#endif +#endif diff --git a/src/rpcsvc/nis_callback.h b/src/rpcsvc/nis_callback.h new file mode 100644 index 0000000..ae92139 --- /dev/null +++ b/src/rpcsvc/nis_callback.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2010, Oracle America, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of the "Oracle America, Inc." nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT HOLDER OR CONTRIBUTORS 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. + */ +#ifndef _RPCSVC_NIS_CALLBACK_H +#define _RPCSVC_NIS_CALLBACK_H 1 + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef nis_object *obj_p; + +struct cback_data { + struct { + u_int entries_len; + obj_p *entries_val; + } entries; +}; +typedef struct cback_data cback_data; + +#define CB_PROG 100302 +#define CB_VERS 1 + +#define CBPROC_RECEIVE 1 +extern bool_t * cbproc_receive_1 (cback_data *, CLIENT *); +extern bool_t * cbproc_receive_1_svc (cback_data *, struct svc_req *); + +#define CBPROC_FINISH 2 +extern void * cbproc_finish_1 (void *, CLIENT *); +extern void * cbproc_finish_1_svc (void *, struct svc_req *); + +#define CBPROC_ERROR 3 +extern void * cbproc_error_1 (nis_error *, CLIENT *); +extern void * cbproc_error_1_svc (nis_error *, struct svc_req *); +extern int cb_prog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); + +/* the xdr functions */ + +extern bool_t xdr_obj_p (XDR *, obj_p*); +extern bool_t xdr_cback_data (XDR *, cback_data*); + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPCVSC_NIS_CALLBACK_H */ diff --git a/src/rpcsvc/nis_callback.x b/src/rpcsvc/nis_callback.x new file mode 100644 index 0000000..0fdca9e --- /dev/null +++ b/src/rpcsvc/nis_callback.x @@ -0,0 +1,63 @@ +%/* +% * Copyright (c) 2010, Oracle America, Inc. +% * +% * Redistribution and use in source and binary forms, with or without +% * modification, are permitted provided that the following conditions are +% * met: +% * +% * * Redistributions of source code must retain the above copyright +% * notice, this list of conditions and the following disclaimer. +% * * 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. +% * * Neither the name of the "Oracle America, Inc." nor the names of its +% * contributors may be used to endorse or promote products derived +% * from this software without specific prior written permission. +% * +% * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +% * "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 +% * COPYRIGHT HOLDER OR CONTRIBUTORS 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. +% */ + +/* + * nis_callback.x + */ + +%#pragma ident "@(#)nis_callback.x 1.7 94/05/03" + +/* + * "@(#)zns_cback.x 1.2 90/09/10" + * + * RPCL description of the Callback Service. + */ + +#ifdef RPC_HDR +%#include +#endif +#ifdef RPC_XDR +%#include "nis_clnt.h" +#endif + +typedef nis_object *obj_p; + +struct cback_data { + obj_p entries<>; /* List of objects */ +}; + +program CB_PROG { + version CB_VERS { + bool CBPROC_RECEIVE(cback_data) = 1; + void CBPROC_FINISH(void) = 2; + void CBPROC_ERROR(nis_error) = 3; + } = 1; +} = 100302; diff --git a/src/rpcsvc/nis_object.x b/src/rpcsvc/nis_object.x new file mode 100644 index 0000000..774b38f --- /dev/null +++ b/src/rpcsvc/nis_object.x @@ -0,0 +1,328 @@ +/* + * nis_object.x + * + * Copyright (c) 2010, Oracle America, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of the "Oracle America, Inc." nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT HOLDER OR CONTRIBUTORS 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. + */ + +%#pragma ident "@(#)nis_object.x 1.12 97/11/19" + +#if RPC_HDR +% +%#ifndef __nis_object_h +%#define __nis_object_h +% +#endif +/* + * This file defines the format for a NIS object in RPC language. + * It is included by the main .x file and the database access protocol + * file. It is common because both of them need to deal with the same + * type of object. Generating the actual code though is a bit messy because + * the nis.x file and the nis_dba.x file will generate xdr routines to + * encode/decode objects when only one set is needed. Such is life when + * one is using rpcgen. + * + * Note, the protocol doesn't specify any limits on such things as + * maximum name length, number of attributes, etc. These are enforced + * by the database backend. When you hit them you will no. Also see + * the db_getlimits() function for fetching the limit values. + * + */ + +/* Some manifest constants, chosen to maximize flexibility without + * plugging the wire full of data. + */ +const NIS_MAXSTRINGLEN = 255; +const NIS_MAXNAMELEN = 1024; +const NIS_MAXATTRNAME = 32; +const NIS_MAXATTRVAL = 2048; +const NIS_MAXCOLUMNS = 64; +const NIS_MAXATTR = 16; +const NIS_MAXPATH = 1024; +const NIS_MAXREPLICAS = 128; +const NIS_MAXLINKS = 16; + +const NIS_PK_NONE = 0; /* no public key (unix/sys auth) */ +const NIS_PK_DH = 1; /* Public key is Diffie-Hellman type */ +const NIS_PK_RSA = 2; /* Public key if RSA type */ +const NIS_PK_KERB = 3; /* Use kerberos style authentication */ +const NIS_PK_DHEXT = 4; /* Extended Diffie-Hellman for RPC-GSS */ + +/* + * The fundamental name type of NIS. The name may consist of two parts, + * the first being the fully qualified name, and the second being an + * optional set of attribute/value pairs. + */ +struct nis_attr { + string zattr_ndx<>; /* name of the index */ + opaque zattr_val<>; /* Value for the attribute. */ +}; + +typedef string nis_name<>; /* The NIS name itself. */ + +/* NIS object types are defined by the following enumeration. The numbers + * they use are based on the following scheme : + * 0 - 1023 are reserved for Sun, + * 1024 - 2047 are defined to be private to a particular tree. + * 2048 - 4095 are defined to be user defined. + * 4096 - ... are reserved for future use. + * + * EOL Alert - The non-prefixed names are present for backward + * compatability only, and will not exist in future releases. Use + * the NIS_* names for future compatability. + */ + +enum zotypes { + + BOGUS_OBJ = 0, /* Uninitialized object structure */ + NO_OBJ = 1, /* NULL object (no data) */ + DIRECTORY_OBJ = 2, /* Directory object describing domain */ + GROUP_OBJ = 3, /* Group object (a list of names) */ + TABLE_OBJ = 4, /* Table object (a database schema) */ + ENTRY_OBJ = 5, /* Entry object (a database record) */ + LINK_OBJ = 6, /* A name link. */ + PRIVATE_OBJ = 7, /* Private object (all opaque data) */ + + NIS_BOGUS_OBJ = 0, /* Uninitialized object structure */ + NIS_NO_OBJ = 1, /* NULL object (no data) */ + NIS_DIRECTORY_OBJ = 2, /* Directory object describing domain */ + NIS_GROUP_OBJ = 3, /* Group object (a list of names) */ + NIS_TABLE_OBJ = 4, /* Table object (a database schema) */ + NIS_ENTRY_OBJ = 5, /* Entry object (a database record) */ + NIS_LINK_OBJ = 6, /* A name link. */ + NIS_PRIVATE_OBJ = 7 /* Private object (all opaque data) */ +}; + +/* + * The types of Name services NIS knows about. They are enumerated + * here. The Binder code will use this type to determine if it has + * a set of library routines that will access the indicated name service. + */ +enum nstype { + UNKNOWN = 0, + NIS = 1, /* Nis Plus Service */ + SUNYP = 2, /* Old NIS Service */ + IVY = 3, /* Nis Plus Plus Service */ + DNS = 4, /* Domain Name Service */ + X500 = 5, /* ISO/CCCIT X.500 Service */ + DNANS = 6, /* Digital DECNet Name Service */ + XCHS = 7, /* Xerox ClearingHouse Service */ + CDS= 8 +}; + +/* + * DIRECTORY - The name service object. These objects identify other name + * servers that are serving some portion of the name space. Each has a + * type associated with it. The resolver library will note whether or not + * is has the needed routines to access that type of service. + * The oarmask structure defines an access rights mask on a per object + * type basis for the name spaces. The only bits currently used are + * create and destroy. By enabling or disabling these access rights for + * a specific object type for a one of the accessor entities (owner, + * group, world) the administrator can control what types of objects + * may be freely added to the name space and which require the + * administrator's approval. + */ +struct oar_mask { + uint32_t oa_rights; /* Access rights mask */ + zotypes oa_otype; /* Object type */ +}; + +struct endpoint { + string uaddr<>; + string family<>; /* Transport family (INET, OSI, etc) */ + string proto<>; /* Protocol (TCP, UDP, CLNP, etc) */ +}; + +/* + * Note: pkey is a netobj which is limited to 1024 bytes which limits the + * keysize to 8192 bits. This is consider to be a reasonable limit for + * the expected lifetime of this service. + */ +struct nis_server { + nis_name name; /* Principal name of the server */ + endpoint ep<>; /* Universal addr(s) for server */ + uint32_t key_type; /* Public key type */ + netobj pkey; /* server's public key */ +}; + +struct directory_obj { + nis_name do_name; /* Name of the directory being served */ + nstype do_type; /* one of NIS, DNS, IVY, YP, or X.500 */ + nis_server do_servers<>; /* <0> == Primary name server */ + uint32_t do_ttl; /* Time To Live (for caches) */ + oar_mask do_armask<>; /* Create/Destroy rights by object type */ +}; + +/* + * ENTRY - This is one row of data from an information base. + * The type value is used by the client library to convert the entry to + * it's internal structure representation. The Table name is a back pointer + * to the table where the entry is stored. This allows the client library + * to determine where to send a request if the client wishes to change this + * entry but got to it through a LINK rather than directly. + * If the entry is a "standalone" entry then this field is void. + */ +const EN_BINARY = 1; /* Indicates value is binary data */ +const EN_CRYPT = 2; /* Indicates the value is encrypted */ +const EN_XDR = 4; /* Indicates the value is XDR encoded */ +const EN_MODIFIED = 8; /* Indicates entry is modified. */ +const EN_ASN1 = 64; /* Means contents use ASN.1 encoding */ + +struct entry_col { + uint32_t ec_flags; /* Flags for this value */ + opaque ec_value<>; /* It's textual value */ +}; + +struct entry_obj { + string en_type<>; /* Type of entry such as "passwd" */ + entry_col en_cols<>; /* Value for the entry */ +}; + +/* + * GROUP - The group object contains a list of NIS principal names. Groups + * are used to authorize principals. Each object has a set of access rights + * for members of its group. Principal names in groups are in the form + * name.directory and recursive groups are expressed as @groupname.directory + */ +struct group_obj { + uint32_t gr_flags; /* Flags controlling group */ + nis_name gr_members<>; /* List of names in group */ +}; + +/* + * LINK - This is the LINK object. It is quite similar to a symbolic link + * in the UNIX filesystem. The attributes in the main object structure are + * relative to the LINK data and not what it points to (like the file system) + * "modify" privleges here indicate the right to modify what the link points + * at and not to modify that actual object pointed to by the link. + */ +struct link_obj { + zotypes li_rtype; /* Real type of the object */ + nis_attr li_attrs<>; /* Attribute/Values for tables */ + nis_name li_name; /* The object's real NIS name */ +}; + +/* + * TABLE - This is the table object. It implements a simple + * data base that applications and use for configuration or + * administration purposes. The role of the table is to group together + * a set of related entries. Tables are the simple database component + * of NIS. Like many databases, tables are logically divided into columns + * and rows. The columns are labeled with indexes and each ENTRY makes + * up a row. Rows may be addressed within the table by selecting one + * or more indexes, and values for those indexes. Each row which has + * a value for the given index that matches the desired value is returned. + * Within the definition of each column there is a flags variable, this + * variable contains flags which determine whether or not the column is + * searchable, contains binary data, and access rights for the entry objects + * column value. + */ + +const TA_BINARY = 1; /* Means table data is binary */ +const TA_CRYPT = 2; /* Means value should be encrypted */ +const TA_XDR = 4; /* Means value is XDR encoded */ +const TA_SEARCHABLE = 8; /* Means this column is searchable */ +const TA_CASE = 16; /* Means this column is Case Sensitive */ +const TA_MODIFIED = 32; /* Means this columns attrs are modified*/ +const TA_ASN1 = 64; /* Means contents use ASN.1 encoding */ + +struct table_col { + string tc_name<64>; /* Column Name */ + uint32_t tc_flags; /* control flags */ + uint32_t tc_rights; /* Access rights mask */ +}; + +struct table_obj { + string ta_type<64>; /* Table type such as "passwd" */ + int ta_maxcol; /* Total number of columns */ + u_char ta_sep; /* Separator character */ + table_col ta_cols<>; /* The number of table indexes */ + string ta_path<>; /* A search path for this table */ +}; + +/* + * This union joins together all of the currently known objects. + */ +union objdata switch (zotypes zo_type) { + case NIS_DIRECTORY_OBJ : + struct directory_obj di_data; + case NIS_GROUP_OBJ : + struct group_obj gr_data; + case NIS_TABLE_OBJ : + struct table_obj ta_data; + case NIS_ENTRY_OBJ: + struct entry_obj en_data; + case NIS_LINK_OBJ : + struct link_obj li_data; + case NIS_PRIVATE_OBJ : + opaque po_data<>; + case NIS_NO_OBJ : + void; + case NIS_BOGUS_OBJ : + void; + default : + void; +}; + +/* + * This is the basic NIS object data type. It consists of a generic part + * which all objects contain, and a specialized part which varies depending + * on the type of the object. All of the specialized sections have been + * described above. You might have wondered why they all start with an + * integer size, followed by the useful data. The answer is, when the + * server doesn't recognize the type returned it treats it as opaque data. + * And the definition for opaque data is {int size; char *data;}. In this + * way, servers and utility routines that do not understand a given type + * may still pass it around. One has to be careful in setting + * this variable accurately, it must take into account such things as + * XDR padding of structures etc. The best way to set it is to note one's + * position in the XDR encoding stream, encode the structure, look at the + * new position and calculate the size. + */ +struct nis_oid { + uint32_t ctime; /* Time of objects creation */ + uint32_t mtime; /* Time of objects modification */ +}; + +struct nis_object { + nis_oid zo_oid; /* object identity verifier. */ + nis_name zo_name; /* The NIS name for this object */ + nis_name zo_owner; /* NIS name of object owner. */ + nis_name zo_group; /* NIS name of access group. */ + nis_name zo_domain; /* The administrator for the object */ + uint32_t zo_access; /* Access rights (owner, group, world) */ + uint32_t zo_ttl; /* Object's time to live in seconds. */ + objdata zo_data; /* Data structure for this type */ +}; +#if RPC_HDR +% +%#endif /* if __nis_object_h */ +% +#endif diff --git a/src/rpcsvc/nis_tags.h b/src/rpcsvc/nis_tags.h new file mode 100644 index 0000000..c2dc7fd --- /dev/null +++ b/src/rpcsvc/nis_tags.h @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2010, Oracle America, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of the "Oracle America, Inc." nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT HOLDER OR CONTRIBUTORS 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. + */ + +/* + * nis_tags.h + * + * This file contains the tags and statistics definitions. It is + * automatically included by nis.h + */ + +#ifndef _RPCSVC_NIS_TAGS_H +#define _RPCSVC_NIS_TAGS_H + +#if 0 +#pragma ident "@(#)nis_tags.h 1.16 96/10/25" +#endif +/* from file: zns_tags.h 1.7 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#define NIS_DIR "data" + +/* Lookup and List function flags */ +#define FOLLOW_LINKS (1<<0) /* Follow link objects */ +#define FOLLOW_PATH (1<<1) /* Follow the path in a table */ +#define HARD_LOOKUP (1<<2) /* Block until successful */ +#define ALL_RESULTS (1<<3) /* Retrieve all results */ +#define NO_CACHE (1<<4) /* Do not return 'cached' results */ +#define MASTER_ONLY (1<<5) /* Get value only from master server */ +#define EXPAND_NAME (1<<6) /* Expand partitially qualified names */ + +/* Semantic modification for table operations flags */ +#define RETURN_RESULT (1<<7) /* Return resulting object to client */ +#define ADD_OVERWRITE (1<<8) /* Allow overwrites on ADD */ +#define REM_MULTIPLE (1<<9) /* Allow wildcard deletes */ +#define MOD_SAMEOBJ (1<<10) /* Check modified object before write */ +#define ADD_RESERVED (1<<11) /* Spare ADD semantic */ +#define REM_RESERVED (1<<12) /* Spare REM semantic */ +#define MOD_EXCLUSIVE (1<<13) /* Modify no overwrite on modified keys */ + +/* Lookup and List function flags (continued) */ +#define SOFT_LOOKUP (1<<14) /* The "old default" return on failure */ + +/* Transport specific modifications to the operation */ +#define USE_DGRAM (1<<16) /* Use a datagram transport */ +#define NO_AUTHINFO (1<<17) /* Don't bother attaching auth info */ + +/* + * Declarations for "standard" NIS+ tags + * State variable tags have values 0 - 2047 + * Statistic tags have values 2048 - 65535 + * User Tags have values >2^16 + */ +#define TAG_DEBUG 1 /* set debug level */ +#define TAG_STATS 2 /* Enable/disable statistics */ +#define TAG_GCACHE 3 /* Flush the Group Cache */ +#define TAG_GCACHE_ALL TAG_GCACHE +#define TAG_DCACHE 4 /* Flush the directory cache */ +#define TAG_DCACHE_ONE TAG_DCACHE +#define TAG_OCACHE 5 /* Flush the Object Cache */ +#define TAG_SECURE 6 /* Set the security level */ +#define TAG_TCACHE_ONE 7 /* Flush the table cache */ +#define TAG_DCACHE_ALL 8 /* Flush entire directory cache */ +#define TAG_TCACHE_ALL 9 /* Flush entire table cache */ +#define TAG_GCACHE_ONE 10 /* Flush one group object */ +#define TAG_DCACHE_ONE_REFRESH 11 /* Flush and refresh one DO */ +#define TAG_READONLY 12 /* Set read only mode */ +#define TAG_READWRITE 14 /* Reset read-write mode */ + +#define TAG_OPSTATS 2048 /* NIS+ operations statistics */ +#define TAG_THREADS 2049 /* Child process/thread status */ +#define TAG_HEAP 2050 /* Heap usage statistics */ +#define TAG_UPDATES 2051 /* Updates to this service */ +#define TAG_VISIBLE 2052 /* First update that isn't replicated */ +#define TAG_S_DCACHE 2053 /* Directory cache statistics */ +#define TAG_S_OCACHE 2054 /* Object cache statistics */ +#define TAG_S_GCACHE 2055 /* Group cache statistics */ +#define TAG_S_STORAGE 2056 /* Group cache statistics */ +#define TAG_UPTIME 2057 /* Time that server has been up */ +#define TAG_DIRLIST 2058 /* Dir served by this server */ +#define TAG_NISCOMPAT 2059 /* Whether supports NIS compat mode */ +#define TAG_DNSFORWARDING 2060 /* Whether DNS forwarding supported */ +#define TAG_SECURITY_LEVEL 2061 /* Security level of the server */ +#define TAG_ROOTSERVER 2062 /* Whether root server */ + +/* + * Declarations for the Group object flags. Currently + * there are only 3. + */ +#define IMPMEM_GROUPS 1 /* Implicit Membership allowed */ +#define RECURS_GROUPS 2 /* Recursive Groups allowed */ +#define NEGMEM_GROUPS 4 /* Negative Groups allowed */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RPCSVC_NIS_TAGS_H */ diff --git a/src/rpcsvc/nislib.h b/src/rpcsvc/nislib.h new file mode 100644 index 0000000..d1988c2 --- /dev/null +++ b/src/rpcsvc/nislib.h @@ -0,0 +1,288 @@ +/* Copyright (C) 1997-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + +#ifndef __RPCSVC_NISLIB_H__ +#define __RPCSVC_NISLIB_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef const char *const_nis_name; + +/* nis_names: These functions are used to locate and manipulate all NIS+ + * objects except the NIS+ entry objects. + * + * nis_lookup (name, flags) resolves a NIS+ name and returns a copy of + * that object from a NIS+ server. + * const nis_name name: name of the object to be resolved + * unsigned int flags: logically ORing zero or more flags (FOLLOW_LINKS, + * HARD_LOOKUP, [NO_CACHE], MASTER_ONLY, EXPAND_NAME) + * + * nis_add (name, obj) adds objects to the NIS+ namespace. + * const nis_name name: fully qualified NIS+ name. + * const nis_object *obj: object members zo_name and zo_domain will be + * constructed from name. + * + * nis_remove (name, obj) removes objects from the NIS+ namespace. + * const nis_name name: fully qualified NIS+ name. + * const nis_object *obj: if not NULL, it is assumed to point to a copy + * of the object being removed. In this case, if + * the object on the server does not have the same + * object identifier as the object being passed, + * the operation will fail with the NIS_NOTSAMEOBJ + * error. + * + * nis_modify (name, obj) can change specific attributes of an object + * that already exists in the namespace. + */ +extern nis_result *nis_lookup (const_nis_name name, unsigned int flags) + ; +extern nis_result *nis_add (const_nis_name name, const nis_object *obj) + ; +extern nis_result *nis_remove (const_nis_name name, + const nis_object *obj); +extern nis_result *nis_modify (const_nis_name name, + const nis_object *obj); + +/* nis_tables: These functions are used to search and modify NIS+ tables. + * + * nis_list (table_name, flags, callback(table_name, obj, userdata), userdata) + * search a table in the NIS+ namespace. + * const nis_name table_name: indexed name ([xx=yy],table.dir) + * unsigned int flags: logically ORing one or more flags (FOLLOW_LINKS, + * [FOLLOW_PATH], HARD_LOOKUP, [ALL_RESULTS], [NO_CACHE], + * MASTER_ONLY, EXPAND_NAME, RETURN_RESULT) + * callback(): callback is an optional pointer to a function that will + * process the ENTRY type objects that are returned from the + * search. If this pointer is NULL, then all entries that match + * the search criteria are returned in the nis_result structure, + * otherwise this function will be called once for each + * entry returned. + * void *userdata: passed to callback function along with the returned + * entry object. + * + * nis_add_entry (table_name, obj, flags) will add the NIS+ object to the + * NIS+ table_name. + * const nis_name table_name + * const nis_object *obj + * unsigned int flags: 0, ADD_OVERWRITE, RETURN_RESULT + * + * nis_modify_entry (name, obj, flags) modifies an object identified by name. + * const nis_name name: object identifier + * const nis_object *obj: should point to an entry with the EN_MODIFIED + * flag set in each column that contains new + * information. + * unsigned int flags: 0, MOD_SAMEOBJ, RETURN_RESULT + * + * nis_remove_entry (table_name, obj, flags) removes a set of entries + * identified by table_name from the table. + * const nis_name table_name: indexed NIS+ name + * const nis_object *obj: if obj is non-null, it is presumed to point to + * a cached copy of the entry. When the removal is + * attempted, and the object that would be removed + * is not the same as the cached object pointed to + * by object then the operation will fail with an + * NIS_NOTSAMEOBJ error + * unsigned int flags: 0, REM_MULTIPLE + * + * nis_first_entry (table_name) fetches entries from a table one at a time. + * const nis_name table_name + * + * nis_next_entry (table_name, cookie) retrieves the "next" entry from a + * table specified by table_name. + * const nis_name table_name: + * const netobj *cookie: The value of cookie from the nis_result structure + * form the previous call. + */ +extern nis_result *nis_list (const_nis_name __name, unsigned int __flags, + int (*__callback)(const_nis_name __table_name, + const nis_object *__obj, + const void *__userdata), + const void *__userdata); +extern nis_result *nis_add_entry (const_nis_name __table_name, + const nis_object *__obj, + unsigned int __flags); +extern nis_result *nis_modify_entry (const_nis_name __name, + const nis_object *__obj, + unsigned int __flags); +extern nis_result *nis_remove_entry (const_nis_name __table_name, + const nis_object *__obj, + unsigned int __flags); +extern nis_result *nis_first_entry (const_nis_name __table_name); +extern nis_result *nis_next_entry (const_nis_name __table_name, + const netobj *__cookie); +/* +** nis_server +*/ +extern nis_error nis_mkdir (const_nis_name __dirname, + const nis_server *__machine); +extern nis_error nis_rmdir (const_nis_name __dirname, + const nis_server *__machine); +extern nis_error nis_servstate (const nis_server *__machine, + const nis_tag *__tags, int __numtags, + nis_tag **__result); +extern nis_error nis_stats (const nis_server *__machine, + const nis_tag *__tags, int __numtags, + nis_tag **__result); +extern void nis_freetags (nis_tag *__tags, int __numtags); +extern nis_server **nis_getservlist (const_nis_name __dirname); +extern void nis_freeservlist (nis_server **__machines); + +/* +** nis_subr +*/ +extern nis_name nis_leaf_of (const_nis_name __name); +extern nis_name nis_leaf_of_r (const_nis_name __name, char *__buffer, + size_t __buflen); +extern nis_name nis_name_of (const_nis_name __name); +extern nis_name nis_name_of_r (const_nis_name __name, char *__buffer, + size_t __buflen); +extern nis_name nis_domain_of (const_nis_name __name); +extern nis_name nis_domain_of_r (const_nis_name __name, char *__buffer, + size_t __buflen); +extern nis_name *nis_getnames (const_nis_name __name); +extern void nis_freenames (nis_name *__namelist); +extern name_pos nis_dir_cmp (const_nis_name __n1, const_nis_name __n2); +extern nis_object *nis_clone_object (const nis_object *__src, + nis_object *__dest); +extern void nis_destroy_object (nis_object *__obj); +extern void nis_print_object (const nis_object *__obj); + +/* +** nis_local_names +*/ +extern nis_name nis_local_group (void); +extern nis_name nis_local_directory (void); +extern nis_name nis_local_principal (void); +extern nis_name nis_local_host (void); + +/* +** nis_error +*/ +extern const char *nis_sperrno (const nis_error __status); +extern void nis_perror (const nis_error __status, const char *__label); +extern void nis_lerror (const nis_error __status, const char *__label); +extern char *nis_sperror (const nis_error status, const char *__label); +extern char *nis_sperror_r (const nis_error __status, const char *__label, + char *__buffer, size_t __buflen); +/* +** nis_groups +*/ +extern bool_t nis_ismember (const_nis_name __principal, + const_nis_name __group); +extern nis_error nis_addmember (const_nis_name __member, + const_nis_name __group); +extern nis_error nis_removemember (const_nis_name __member, + const_nis_name __group); +extern nis_error nis_creategroup (const_nis_name __group, + unsigned int __flags); +extern nis_error nis_destroygroup (const_nis_name __group); +extern void nis_print_group_entry (const_nis_name __group); +extern nis_error nis_verifygroup (const_nis_name __group); + +/* +** nis_ping +*/ +extern void nis_ping (const_nis_name __dirname, uint32_t __utime, + const nis_object *__dirobj); +extern nis_result *nis_checkpoint (const_nis_name __dirname); + +/* +** nis_print (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) +*/ +extern void nis_print_result (const nis_result *__result); +extern void nis_print_rights (unsigned int __rights); +extern void nis_print_directory (const directory_obj *__dirobj); +extern void nis_print_group (const group_obj *__grpobj); +extern void nis_print_table (const table_obj *__tblobj); +extern void nis_print_link (const link_obj *__lnkobj); +extern void nis_print_entry (const entry_obj *__enobj); + +/* +** nis_file (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) +*/ +extern directory_obj *readColdStartFile (void); +extern bool_t writeColdStartFile (const directory_obj *__dirobj); +extern nis_object *nis_read_obj (const char *__obj); +extern bool_t nis_write_obj (const char *__file, const nis_object *__obj); + +/* +** nis_clone - (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) +*/ +extern directory_obj *nis_clone_directory (const directory_obj *__src, + directory_obj *__dest); +extern nis_result *nis_clone_result (const nis_result *__src, + nis_result *__dest); + +/* nis_free - nis_freeresult */ +extern void nis_freeresult (nis_result *__result); +/* (XXX THE FOLLOWING ARE INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */ +extern void nis_free_request (ib_request *__req); +extern void nis_free_directory (directory_obj *__dirobj); +extern void nis_free_object (nis_object *__obj); + +/* (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */ +extern nis_name __nis_default_owner (char *); +extern nis_name __nis_default_group (char *); +extern uint32_t __nis_default_ttl (char *); +extern unsigned int __nis_default_access (char *, unsigned int); +extern fd_result *__nis_finddirectory (directory_obj *, const_nis_name); +extern void __free_fdresult (fd_result *); +extern uint32_t __nis_hash (const void *__keyarg, size_t __len); + +/* NIS+ cache locking */ +extern int __nis_lock_cache (void); +extern int __nis_unlock_cache (void); + +/* (XXX INTERNAL FUNCTIONS, ONLY FOR rpc.nisd AND glibc !!) */ +#if defined (NIS_INTERNAL) + +struct dir_binding +{ + CLIENT *clnt; /* RPC CLIENT handle */ + nis_server *server_val; /* List of servers */ + unsigned int server_len; /* # of servers */ + unsigned int server_used; /* Which server we are bind in the moment ? */ + unsigned int current_ep; /* Which endpoint of the server are in use? */ + unsigned int trys; /* How many server have we tried ? */ + unsigned int class; /* From which class is server_val ? */ + bool_t master_only; /* Is only binded to the master */ + bool_t use_auth; /* Do we use AUTH ? */ + bool_t use_udp; /* Do we use UDP ? */ + struct sockaddr_in addr; /* Server's IP address */ + int socket; /* Server's local socket */ +}; +typedef struct dir_binding dir_binding; + +extern nis_error __nisbind_create (dir_binding *, const nis_server *, + unsigned int, unsigned int, unsigned int, + unsigned int); +extern nis_error __nisbind_connect (dir_binding *); +extern nis_error __nisbind_next (dir_binding *); +extern void __nisbind_destroy (dir_binding *); +extern nis_error __nisfind_server (const_nis_name, int, directory_obj **, + dir_binding *, unsigned int); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __RPCSVC_NISLIB_H__ */ diff --git a/src/rpcsvc/yp.h b/src/rpcsvc/yp.h new file mode 100644 index 0000000..ca5798b --- /dev/null +++ b/src/rpcsvc/yp.h @@ -0,0 +1,304 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef __RPCSVC_YP_H__ +#define __RPCSVC_YP_H__ + +#include + +#define YPMAXRECORD 1024 +#define YPMAXDOMAIN 256 +#define YPMAXMAP 64 +#define YPMAXPEER 64 + +enum ypstat { + YP_TRUE = 1, + YP_NOMORE = 2, + YP_FALSE = 0, + YP_NOMAP = -1, + YP_NODOM = -2, + YP_NOKEY = -3, + YP_BADOP = -4, + YP_BADDB = -5, + YP_YPERR = -6, + YP_BADARGS = -7, + YP_VERS = -8, +}; +typedef enum ypstat ypstat; + +enum ypxfrstat { + YPXFR_SUCC = 1, + YPXFR_AGE = 2, + YPXFR_NOMAP = -1, + YPXFR_NODOM = -2, + YPXFR_RSRC = -3, + YPXFR_RPC = -4, + YPXFR_MADDR = -5, + YPXFR_YPERR = -6, + YPXFR_BADARGS = -7, + YPXFR_DBM = -8, + YPXFR_FILE = -9, + YPXFR_SKEW = -10, + YPXFR_CLEAR = -11, + YPXFR_FORCE = -12, + YPXFR_XFRERR = -13, + YPXFR_REFUSED = -14, +}; +typedef enum ypxfrstat ypxfrstat; + +typedef char *domainname; +typedef char *mapname; +typedef char *peername; + +typedef struct { + u_int keydat_len; + char *keydat_val; +} keydat; + +typedef struct { + u_int valdat_len; + char *valdat_val; +} valdat; + +struct ypmap_parms { + domainname domain; + mapname map; + u_int ordernum; + peername peer; +}; +typedef struct ypmap_parms ypmap_parms; + +struct ypreq_key { + domainname domain; + mapname map; + keydat key; +}; +typedef struct ypreq_key ypreq_key; + +struct ypreq_nokey { + domainname domain; + mapname map; +}; +typedef struct ypreq_nokey ypreq_nokey; + +struct ypreq_xfr { + ypmap_parms map_parms; + u_int transid; + u_int prog; + u_int port; +}; +typedef struct ypreq_xfr ypreq_xfr; + +struct ypresp_val { + ypstat stat; + valdat val; +}; +typedef struct ypresp_val ypresp_val; + +struct ypresp_key_val { + ypstat stat; + valdat val; + keydat key; +}; +typedef struct ypresp_key_val ypresp_key_val; + +struct ypresp_master { + ypstat stat; + peername peer; +}; +typedef struct ypresp_master ypresp_master; + +struct ypresp_order { + ypstat stat; + u_int ordernum; +}; +typedef struct ypresp_order ypresp_order; + +struct ypresp_all { + bool_t more; + union { + ypresp_key_val val; + } ypresp_all_u; +}; +typedef struct ypresp_all ypresp_all; + +struct ypresp_xfr { + u_int transid; + ypxfrstat xfrstat; +}; +typedef struct ypresp_xfr ypresp_xfr; + +struct ypmaplist { + mapname map; + struct ypmaplist *next; +}; +typedef struct ypmaplist ypmaplist; + +struct ypresp_maplist { + ypstat stat; + ypmaplist *maps; +}; +typedef struct ypresp_maplist ypresp_maplist; + +enum yppush_status { + YPPUSH_SUCC = 1, + YPPUSH_AGE = 2, + YPPUSH_NOMAP = -1, + YPPUSH_NODOM = -2, + YPPUSH_RSRC = -3, + YPPUSH_RPC = -4, + YPPUSH_MADDR = -5, + YPPUSH_YPERR = -6, + YPPUSH_BADARGS = -7, + YPPUSH_DBM = -8, + YPPUSH_FILE = -9, + YPPUSH_SKEW = -10, + YPPUSH_CLEAR = -11, + YPPUSH_FORCE = -12, + YPPUSH_XFRERR = -13, + YPPUSH_REFUSED = -14, +}; +typedef enum yppush_status yppush_status; + +struct yppushresp_xfr { + u_int transid; + yppush_status status; +}; +typedef struct yppushresp_xfr yppushresp_xfr; + +enum ypbind_resptype { + YPBIND_SUCC_VAL = 1, + YPBIND_FAIL_VAL = 2, +}; +typedef enum ypbind_resptype ypbind_resptype; + +struct ypbind_binding { + char ypbind_binding_addr[4]; + char ypbind_binding_port[2]; +}; +typedef struct ypbind_binding ypbind_binding; + +struct ypbind_resp { + ypbind_resptype ypbind_status; + union { + u_int ypbind_error; + ypbind_binding ypbind_bindinfo; + } ypbind_resp_u; +}; +typedef struct ypbind_resp ypbind_resp; + +#define YPBIND_ERR_ERR 1 +#define YPBIND_ERR_NOSERV 2 +#define YPBIND_ERR_RESC 3 + +struct ypbind_setdom { + domainname ypsetdom_domain; + ypbind_binding ypsetdom_binding; + u_int ypsetdom_vers; +}; +typedef struct ypbind_setdom ypbind_setdom; + +#define YPPROG 100004 +#define YPVERS 2 + +#ifdef __cplusplus +extern "C" { +#endif + +#define YPPROC_NULL 0 +extern void * ypproc_null_2(void *, CLIENT *); +extern void * ypproc_null_2_svc(void *, struct svc_req *); +#define YPPROC_DOMAIN 1 +extern bool_t * ypproc_domain_2(domainname *, CLIENT *); +extern bool_t * ypproc_domain_2_svc(domainname *, struct svc_req *); +#define YPPROC_DOMAIN_NONACK 2 +extern bool_t * ypproc_domain_nonack_2(domainname *, CLIENT *); +extern bool_t * ypproc_domain_nonack_2_svc(domainname *, struct svc_req *); +#define YPPROC_MATCH 3 +extern ypresp_val * ypproc_match_2(ypreq_key *, CLIENT *); +extern ypresp_val * ypproc_match_2_svc(ypreq_key *, struct svc_req *); +#define YPPROC_FIRST 4 +extern ypresp_key_val * ypproc_first_2(ypreq_key *, CLIENT *); +extern ypresp_key_val * ypproc_first_2_svc(ypreq_key *, struct svc_req *); +#define YPPROC_NEXT 5 +extern ypresp_key_val * ypproc_next_2(ypreq_key *, CLIENT *); +extern ypresp_key_val * ypproc_next_2_svc(ypreq_key *, struct svc_req *); +#define YPPROC_XFR 6 +extern ypresp_xfr * ypproc_xfr_2(ypreq_xfr *, CLIENT *); +extern ypresp_xfr * ypproc_xfr_2_svc(ypreq_xfr *, struct svc_req *); +#define YPPROC_CLEAR 7 +extern void * ypproc_clear_2(void *, CLIENT *); +extern void * ypproc_clear_2_svc(void *, struct svc_req *); +#define YPPROC_ALL 8 +extern ypresp_all * ypproc_all_2(ypreq_nokey *, CLIENT *); +extern ypresp_all * ypproc_all_2_svc(ypreq_nokey *, struct svc_req *); +#define YPPROC_MASTER 9 +extern ypresp_master * ypproc_master_2(ypreq_nokey *, CLIENT *); +extern ypresp_master * ypproc_master_2_svc(ypreq_nokey *, struct svc_req *); +#define YPPROC_ORDER 10 +extern ypresp_order * ypproc_order_2(ypreq_nokey *, CLIENT *); +extern ypresp_order * ypproc_order_2_svc(ypreq_nokey *, struct svc_req *); +#define YPPROC_MAPLIST 11 +extern ypresp_maplist * ypproc_maplist_2(domainname *, CLIENT *); +extern ypresp_maplist * ypproc_maplist_2_svc(domainname *, struct svc_req *); +extern int ypprog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t); + +#define YPPUSH_XFRRESPPROG 0x40000000 +#define YPPUSH_XFRRESPVERS 1 + +#define YPPUSHPROC_NULL 0 +extern void * yppushproc_null_1(void *, CLIENT *); +extern void * yppushproc_null_1_svc(void *, struct svc_req *); +#define YPPUSHPROC_XFRRESP 1 +extern void * yppushproc_xfrresp_1(yppushresp_xfr *, CLIENT *); +extern void * yppushproc_xfrresp_1_svc(yppushresp_xfr *, struct svc_req *); +extern int yppush_xfrrespprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); + +#define YPBINDPROG 100007 +#define YPBINDVERS 2 + +#define YPBINDPROC_NULL 0 +extern void * ypbindproc_null_2(void *, CLIENT *); +extern void * ypbindproc_null_2_svc(void *, struct svc_req *); +#define YPBINDPROC_DOMAIN 1 +extern ypbind_resp * ypbindproc_domain_2(domainname *, CLIENT *); +extern ypbind_resp * ypbindproc_domain_2_svc(domainname *, struct svc_req *); +#define YPBINDPROC_SETDOM 2 +extern void * ypbindproc_setdom_2(ypbind_setdom *, CLIENT *); +extern void * ypbindproc_setdom_2_svc(ypbind_setdom *, struct svc_req *); +extern int ypbindprog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t); + +/* the xdr functions */ +extern bool_t xdr_ypstat (XDR *, ypstat*); +extern bool_t xdr_ypxfrstat (XDR *, ypxfrstat*); +extern bool_t xdr_domainname (XDR *, domainname*); +extern bool_t xdr_mapname (XDR *, mapname*); +extern bool_t xdr_peername (XDR *, peername*); +extern bool_t xdr_keydat (XDR *, keydat*); +extern bool_t xdr_valdat (XDR *, valdat*); +extern bool_t xdr_ypmap_parms (XDR *, ypmap_parms*); +extern bool_t xdr_ypreq_key (XDR *, ypreq_key*); +extern bool_t xdr_ypreq_nokey (XDR *, ypreq_nokey*); +extern bool_t xdr_ypreq_xfr (XDR *, ypreq_xfr*); +extern bool_t xdr_ypresp_val (XDR *, ypresp_val*); +extern bool_t xdr_ypresp_key_val (XDR *, ypresp_key_val*); +extern bool_t xdr_ypresp_master (XDR *, ypresp_master*); +extern bool_t xdr_ypresp_order (XDR *, ypresp_order*); +extern bool_t xdr_ypresp_all (XDR *, ypresp_all*); +extern bool_t xdr_ypresp_xfr (XDR *, ypresp_xfr*); +extern bool_t xdr_ypmaplist (XDR *, ypmaplist*); +extern bool_t xdr_ypresp_maplist (XDR *, ypresp_maplist*); +extern bool_t xdr_yppush_status (XDR *, yppush_status*); +extern bool_t xdr_yppushresp_xfr (XDR *, yppushresp_xfr*); +extern bool_t xdr_ypbind_resptype (XDR *, ypbind_resptype*); +extern bool_t xdr_ypbind_binding (XDR *, ypbind_binding*); +extern bool_t xdr_ypbind_resp (XDR *, ypbind_resp*); +extern bool_t xdr_ypbind_setdom (XDR *, ypbind_setdom*); + +#ifdef __cplusplus +} +#endif + +#endif /* !__RPCSVC_YP_H__ */ diff --git a/src/rpcsvc/yp.x b/src/rpcsvc/yp.x new file mode 100644 index 0000000..1e7aeb0 --- /dev/null +++ b/src/rpcsvc/yp.x @@ -0,0 +1,307 @@ +/* @(#)yp.x 2.1 88/08/01 4.0 RPCSRC */ + +/* + * Copyright (c) 2010 Oracle America, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of the "Oracle America, Inc." nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT HOLDER OR CONTRIBUTORS 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. + */ + +/* + * Protocol description file for the Yellow Pages Service + */ + +const YPMAXRECORD = 1024; +const YPMAXDOMAIN = 256; +const YPMAXMAP = 64; +const YPMAXPEER = 64; + + +enum ypstat { + YP_TRUE = 1, + YP_NOMORE = 2, + YP_FALSE = 0, + YP_NOMAP = -1, + YP_NODOM = -2, + YP_NOKEY = -3, + YP_BADOP = -4, + YP_BADDB = -5, + YP_YPERR = -6, + YP_BADARGS = -7, + YP_VERS = -8 +}; + + +enum ypxfrstat { + YPXFR_SUCC = 1, + YPXFR_AGE = 2, + YPXFR_NOMAP = -1, + YPXFR_NODOM = -2, + YPXFR_RSRC = -3, + YPXFR_RPC = -4, + YPXFR_MADDR = -5, + YPXFR_YPERR = -6, + YPXFR_BADARGS = -7, + YPXFR_DBM = -8, + YPXFR_FILE = -9, + YPXFR_SKEW = -10, + YPXFR_CLEAR = -11, + YPXFR_FORCE = -12, + YPXFR_XFRERR = -13, + YPXFR_REFUSED = -14 +}; + + +typedef string domainname; +typedef string mapname; +typedef string peername; +typedef opaque keydat; +typedef opaque valdat; + + +struct ypmap_parms { + domainname domain; + mapname map; + unsigned int ordernum; + peername peer; +}; + +struct ypreq_key { + domainname domain; + mapname map; + keydat key; +}; + +struct ypreq_nokey { + domainname domain; + mapname map; +}; + +struct ypreq_xfr { + ypmap_parms map_parms; + unsigned int transid; + unsigned int prog; + unsigned int port; +}; + + +struct ypresp_val { + ypstat stat; + valdat val; +}; + +struct ypresp_key_val { + ypstat stat; +#ifdef STUPID_SUN_BUG + /* This is the form as distributed by Sun. But even the Sun NIS + servers expect the values in the other order. So their + implementation somehow must change the order internally. We + don't want to follow this bad example since the user should be + able to use rpcgen on this file. */ + keydat key; + valdat val; +#else + valdat val; + keydat key; +#endif +}; + + +struct ypresp_master { + ypstat stat; + peername peer; +}; + +struct ypresp_order { + ypstat stat; + unsigned int ordernum; +}; + +union ypresp_all switch (bool more) { +case TRUE: + ypresp_key_val val; +case FALSE: + void; +}; + +struct ypresp_xfr { + unsigned int transid; + ypxfrstat xfrstat; +}; + +struct ypmaplist { + mapname map; + ypmaplist *next; +}; + +struct ypresp_maplist { + ypstat stat; + ypmaplist *maps; +}; + +enum yppush_status { + YPPUSH_SUCC = 1, /* Success */ + YPPUSH_AGE = 2, /* Master's version not newer */ + YPPUSH_NOMAP = -1, /* Can't find server for map */ + YPPUSH_NODOM = -2, /* Domain not supported */ + YPPUSH_RSRC = -3, /* Local resource alloc failure */ + YPPUSH_RPC = -4, /* RPC failure talking to server */ + YPPUSH_MADDR = -5, /* Can't get master address */ + YPPUSH_YPERR = -6, /* YP server/map db error */ + YPPUSH_BADARGS = -7, /* Request arguments bad */ + YPPUSH_DBM = -8, /* Local dbm operation failed */ + YPPUSH_FILE = -9, /* Local file I/O operation failed */ + YPPUSH_SKEW = -10, /* Map version skew during transfer */ + YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ + YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */ + YPPUSH_XFRERR = -13, /* ypxfr error */ + YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */ +}; + +struct yppushresp_xfr { + unsigned transid; + yppush_status status; +}; + +/* + * Response structure and overall result status codes. Success and failure + * represent two separate response message types. + */ + +enum ypbind_resptype { + YPBIND_SUCC_VAL = 1, + YPBIND_FAIL_VAL = 2 +}; + +struct ypbind_binding { + opaque ypbind_binding_addr[4]; /* In network order */ + opaque ypbind_binding_port[2]; /* In network order */ +}; + +union ypbind_resp switch (ypbind_resptype ypbind_status) { +case YPBIND_FAIL_VAL: + unsigned ypbind_error; +case YPBIND_SUCC_VAL: + ypbind_binding ypbind_bindinfo; +}; + +/* Detailed failure reason codes for response field ypbind_error*/ + +const YPBIND_ERR_ERR = 1; /* Internal error */ +const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */ +const YPBIND_ERR_RESC = 3; /* System resource allocation failure */ + + +/* + * Request data structure for ypbind "Set domain" procedure. + */ +struct ypbind_setdom { + domainname ypsetdom_domain; + ypbind_binding ypsetdom_binding; + unsigned ypsetdom_vers; +}; + + +/* + * YP access protocol + */ +program YPPROG { + version YPVERS { + void + YPPROC_NULL(void) = 0; + + bool + YPPROC_DOMAIN(domainname) = 1; + + bool + YPPROC_DOMAIN_NONACK(domainname) = 2; + + ypresp_val + YPPROC_MATCH(ypreq_key) = 3; + + ypresp_key_val + YPPROC_FIRST(ypreq_key) = 4; + + ypresp_key_val + YPPROC_NEXT(ypreq_key) = 5; + + ypresp_xfr + YPPROC_XFR(ypreq_xfr) = 6; + + void + YPPROC_CLEAR(void) = 7; + + ypresp_all + YPPROC_ALL(ypreq_nokey) = 8; + + ypresp_master + YPPROC_MASTER(ypreq_nokey) = 9; + + ypresp_order + YPPROC_ORDER(ypreq_nokey) = 10; + + ypresp_maplist + YPPROC_MAPLIST(domainname) = 11; + } = 2; +} = 100004; + + +/* + * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR + */ +program YPPUSH_XFRRESPPROG { + version YPPUSH_XFRRESPVERS { + void + YPPUSHPROC_NULL(void) = 0; + +#ifdef STUPID_SUN_BUG + /* This is the form as distributed by Sun. + But this is not what the programs use. */ + yppushresp_xfr + YPPUSHPROC_XFRRESP(void) = 1; +#else + void + YPPUSHPROC_XFRRESP(yppushresp_xfr) = 1; +#endif + } = 1; +} = 0x40000000; /* transient: could be anything up to 0x5fffffff */ + +/* + * YP binding protocol + */ +program YPBINDPROG { + version YPBINDVERS { + void + YPBINDPROC_NULL(void) = 0; + + ypbind_resp + YPBINDPROC_DOMAIN(domainname) = 1; + + void + YPBINDPROC_SETDOM(ypbind_setdom) = 2; + } = 2; +} = 100007; diff --git a/src/rpcsvc/yp_prot.h b/src/rpcsvc/yp_prot.h new file mode 100644 index 0000000..1c7d6e5 --- /dev/null +++ b/src/rpcsvc/yp_prot.h @@ -0,0 +1,486 @@ +/* + * This file contains symbols and structures defining the rpc protocol + * between the NIS clients and the NIS servers. The servers + * are the NIS database servers, and the NIS binders. + */ + +#ifndef _RPCSVC_YP_PROT_H +#define _RPCSVC_YP_PROT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * The following procedures are supported by the protocol: + * + * YPPROC_NULL() returns () takes nothing, returns nothing. This indicates + * that the NIS server is alive. + * + * YPPROC_DOMAIN (char *) returns (bool_t) TRUE. Indicates that the + * responding NIS server does serve the named domain; FALSE indicates no + * support. + * + * YPPROC_DOMAIN_NONACK (char *) returns (TRUE) if the NIS server does serve + * the named domain, otherwise does not return. Used in the broadcast case. + * + * YPPROC_MATCH (struct ypreq_key) returns (struct ypresp_val). Returns the + * right-hand value for a passed left-hand key, within a named map and + * domain. + * + * YPPROC_FIRST (struct ypreq_nokey) returns (struct ypresp_key_val). + * Returns the first key-value pair from a named domain and map. + * + * YPPROC_NEXT (struct ypreq_key) returns (struct ypresp_key_val). Returns + * the key-value pair following a passed key-value pair within a named + * domain and map. + * + * YPPROC_XFR (struct ypreq_xfr) returns nothing. Indicates to a server that + * a map should be updated. + * + * YPPROC_NEWXFR (struct ypreq_newxfr) returns nothing. Indicates to a server + * that a map should be updated. Uses protocol independent request struct. + * + * YPPROC_CLEAR takes nothing, returns nothing. Instructs a NIS server to + * close the current map, so that old versions of the disk file don't get + * held open. + * + * YPPROC_ALL (struct ypreq_nokey), returns + * union switch (bool_t more) { + * TRUE: (struct ypresp_key_val); + * FALSE: (struct) {}; + * } + * + * YPPROC_MASTER (struct ypreq_nokey), returns (ypresp_master) + * + * YPPROC_ORDER (struct ypreq_nokey), returns (ypresp_order) + * + * YPPROC_MAPLIST (char *), returns (struct ypmaplist *) + */ + +/* Program and version symbols, magic numbers */ + +#define YPPROG 100004 +#define YPVERS 2 +#define YPVERS_ORIG 1 +#define YPMAXRECORD 1024 +#define YPMAXDOMAIN 256 +#define YPMAXMAP 64 +#define YPMAXPEER 256 + +/* byte size of a large NIS packet */ +#define YPMSGSZ 1600 + +typedef struct keydat { + u_int keydat_len; + char *keydat_val; +} keydat_t; + +typedef struct valdat { + u_int valdat_len; + char *valdat_val; +} valdat_t; + +struct ypmap_parms { + char *domain; /* Null string means not available */ + char *map; /* Null string means not available */ + unsigned int ordernum; /* 0 means not available */ + char *owner; /* Null string means not available */ +}; +typedef struct ypmap_parms ypmap_parms; + +/* + * Request parameter structures + */ + +struct ypreq_key { + char *domain; + char *map; + keydat_t keydat; +}; +typedef struct ypreq_key ypreq_key; + +struct ypreq_nokey { + char *domain; + char *map; +}; +typedef struct ypreq_nokey ypreq_nokey; + +struct ypreq_xfr { + struct ypmap_parms map_parms; + u_int transid; + u_int proto; + u_int port; +}; +typedef struct ypreq_xfr ypreq_xfr; + +struct ypreq_newxfr { + struct ypmap_parms map_parms; + u_int transid; + u_int proto; + char *name; +}; +typedef struct ypreq_newxfr ypreq_newxfr; + +#define ypxfr_domain map_parms.domain +#define ypxfr_map map_parms.map +#define ypxfr_ordernum map_parms.ordernum +#define ypxfr_owner map_parms.owner + +/* Return status values */ + +enum ypstat { + YP_TRUE = 1, /* General purpose success code */ +#define YP_TRUE YP_TRUE + YP_NOMORE = 2, /* No more entries in map */ +#define YP_NOMORE YP_NOMORE + YP_FALSE = 0, /* General purpose failure code */ +#define YP_FALSE YP_FALSE + YP_NOMAP = -1, /* No such map in domain */ +#define YP_NOMAP YP_NOMAP + YP_NODOM = -2, /* Domain not supported */ +#define YP_NODOM YP_NODOM + YP_NOKEY = -3, /* No such key in map */ +#define YP_NOKEY YP_NOKEY + YP_BADOP = -4, /* Invalid operation */ +#define YP_BADOP YP_BADOP + YP_BADDB = -5, /* Server data base is bad */ +#define YP_BADDB YP_BADDB + YP_YPERR = -6, /* NIS server error */ +#define YP_YPERR YP_YPERR + YP_BADARGS = -7, /* Request arguments bad */ +#define YP_BADARGS YP_BADARGS + YP_VERS = -8 /* NIS server version mismatch - server can't supply + requested service. */ +#define YP_VERS YP_VERS +}; +typedef enum ypstat ypstat; + + +enum ypxfrstat { + YPXFR_SUCC = 1, + YPXFR_AGE = 2, + YPXFR_NOMAP = -1, + YPXFR_NODOM = -2, + YPXFR_RSRC = -3, + YPXFR_RPC = -4, + YPXFR_MADDR = -5, + YPXFR_YPERR = -6, + YPXFR_BADARGS = -7, + YPXFR_DBM = -8, + YPXFR_FILE = -9, + YPXFR_SKEW = -10, + YPXFR_CLEAR = -11, + YPXFR_FORCE = -12, + YPXFR_XFRERR = -13, + YPXFR_REFUSED = -14 +}; +typedef enum ypxfrstat ypxfrstat; + +/* + * Response parameter structures + */ + +struct ypresp_val { + ypstat status; + valdat_t valdat; +}; +typedef struct ypresp_val ypresp_val; + +struct ypresp_key_val { + ypstat status; + valdat_t valdat; + keydat_t keydat; +}; +typedef struct ypresp_key_val ypresp_key_val; + +struct ypresp_master { + ypstat status; + char *master; +}; +typedef struct ypresp_master ypresp_master; + +struct ypresp_order { + ypstat status; + unsigned int ordernum; +}; +typedef struct ypresp_order ypresp_order; + +struct ypresp_xfr { + u_int transid; + ypxfrstat xfrstat; +}; +typedef struct ypresp_xfr ypresp_xfr; + +struct ypmaplist { + char *map; +#define ypml_name map + struct ypmaplist *next; +#define ypml_next next +}; +typedef struct ypmaplist ypmaplist; + +struct ypresp_maplist { + ypstat status; + struct ypmaplist *list; +}; +typedef struct ypresp_maplist ypresp_maplist; + + +/* + * Procedure symbols. YPPROC_NULL, YPPROC_DOMAIN, and YPPROC_DOMAIN_NONACK + * must keep the same values (0, 1, and 2) that they had in the first version + * of the protocol. + */ + +#define YPPROC_NULL 0 +#define YPPROC_DOMAIN 1 +#define YPPROC_DOMAIN_NONACK 2 +#define YPPROC_MATCH 3 +#define YPPROC_FIRST 4 +#define YPPROC_NEXT 5 +#define YPPROC_XFR 6 +#define YPPROC_CLEAR 7 +#define YPPROC_ALL 8 +#define YPPROC_MASTER 9 +#define YPPROC_ORDER 10 +#define YPPROC_MAPLIST 11 +#define YPPROC_NEWXFR 12 + +/* + * Protocol between clients and NIS binder servers + */ + +/* + * The following procedures are supported by the protocol: + * + * YPBINDPROC_NULL() returns () + * takes nothing, returns nothing + * + * YPBINDPROC_DOMAIN takes (char *) returns (struct ypbind2_resp) + * + * YPBINDPROC_SETDOM takes (struct ypbind2_setdom) returns nothing + */ + +/* Program and version symbols, magic numbers */ + +#define YPBINDPROG 100007 +#define YPBINDVERS 3 +#define YPBINDVERS_2 2 +#define YPBINDVERS_1 1 + +/* Procedure symbols */ + +#define YPBINDPROC_NULL 0 +#define YPBINDPROC_DOMAIN 1 +#define YPBINDPROC_SETDOM 2 + +/* + * Request and response structures and overall result status codes. + * Success and failure represent two separate response message types. + */ + +enum ypbind_resptype {YPBIND_SUCC_VAL = 1, YPBIND_FAIL_VAL = 2}; +typedef enum ypbind_resptype ypbind_resptype; + +struct ypbind2_binding { + struct in_addr ypbind_binding_addr; /* In network order */ + unsigned short int ypbind_binding_port; /* In network order */ +}; +typedef struct ypbind2_binding ypbind2_binding; + +struct ypbind2_resp { + enum ypbind_resptype ypbind_status; + union { + u_int ypbind_error; + struct ypbind2_binding ypbind_bindinfo; + } ypbind_respbody; +}; +typedef struct ypbind2_resp ypbind2_resp; +#define ypbind2_error ypbind_respbody.ypbind_error +#define ypbind2_bindinfo ypbind_respbody.ypbind_bindinfo +#define ypbind2_addr ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr +#define ypbind2_port ypbind_respbody.ypbind_bindinfo.ypbind_binding_port + +struct ypbind_oldsetdom { + char ypoldsetdom_domain[YPMAXDOMAIN]; + ypbind2_binding ypoldsetdom_binding; +}; +typedef struct ypbind_oldsetdom ypbind_oldsetdom; +#define ypoldsetdom_addr ypoldsetdom_binding.ypbind_binding_addr +#define ypoldsetdom_port ypoldsetdom_binding.ypbind_binding_port + +struct ypbind2_setdom { + char *ypsetdom_domain; + struct ypbind2_binding ypsetdom_binding; + u_int ypsetdom_vers; +}; +typedef struct ypbind2_setdom ypbind2_setdom; +#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr +#define ypsetdom_port ypsetdom_binding.ypbind_binding_port + +struct ypbind3_binding { + struct netconfig *ypbind_nconf; + struct netbuf *ypbind_svcaddr; + char *ypbind_servername; + /* that's the highest version number that the used + ypserv supports, normally YPVERS */ + rpcvers_t ypbind_hi_vers; + /* the lowest version number that the used + ypserv supports, on Solaris 0 or YPVERS, too */ + rpcvers_t ypbind_lo_vers; +}; +typedef struct ypbind3_binding ypbind3_binding; + +struct ypbind3_resp { + enum ypbind_resptype ypbind_status; + union { + u_long ypbind_error; + struct ypbind3_binding *ypbind_bindinfo; + } ypbind_respbody; +}; +typedef struct ypbind3_resp ypbind3_resp; +#define ypbind3_error ypbind_respbody.ypbind_error +#define ypbind3_bindinfo ypbind_respbody.ypbind_bindinfo +#define ypbind3_nconf ypbind_respbody.ypbind_bindinfo->ypbind_nconf +#define ypbind3_svcaddr ypbind_respbody.ypbind_bindinfo->ypbind_svcaddr +#define ypbind3_servername ypbind_respbody.ypbind_bindinfo->ypbind_servername +#define ypbind3_hi_vers ypbind_respbody.ypbind_bindinfo->ypbind_hi_vers +#define ypbind3_lo_vers ypbind_respbody.ypbind_bindinfo->ypbind_lo_vers + +struct ypbind3_setdom { + char *ypsetdom_domain; + struct ypbind3_binding *ypsetdom_bindinfo; +}; +typedef struct ypbind3_setdom ypbind3_setdom; +#define ypsetdom3_nconf ypsetdom_bindinfo->ypbind_nconf +#define ypsetdom3_svcaddr ypsetdom_bindinfo->ypbind_svcaddr +#define ypsetdom3_servername ypsetdom_bindinfo->ypbind_servername +#define ypsetdom3_hi_vers ypsetdom_bindinfo->ypbind_hi_vers +#define ypsetdom3_lo_vers ypsetdom_bindinfo->ypbind_lo_vers + + +/* Detailed failure reason codes for response field ypbind_error*/ + +#define YPBIND_ERR_ERR 1 /* Internal error */ +#define YPBIND_ERR_NOSERV 2 /* No bound server for passed domain */ +#define YPBIND_ERR_RESC 3 /* System resource allocation failure */ +#define YPBIND_ERR_NODOMAIN 4 /* Domain doesn't exist */ + +/* + * Protocol between clients (ypxfr, only) and yppush + * yppush speaks a protocol in the transient range, which + * is supplied to ypxfr as a command-line parameter when it + * is activated by ypserv. + */ +#define YPPUSHVERS 1 +#define YPPUSHVERS_ORIG 1 + +/* Procedure symbols */ + +#define YPPUSHPROC_NULL 0 +#define YPPUSHPROC_XFRRESP 1 + +/* Status values for yppushresp_xfr.status */ + +enum yppush_status { + YPPUSH_SUCC = 1, /* Success */ +#define YPPUSH_SUCC YPPUSH_SUCC + YPPUSH_AGE = 2, /* Master's version not newer */ +#define YPPUSH_AGE YPPUSH_AGE + YPPUSH_NOMAP = -1, /* Can't find server for map */ +#define YPPUSH_NOMAP YPPUSH_NOMAP + YPPUSH_NODOM = -2, /* Domain not supported */ +#define YPPUSH_NODOM YPPUSH_NODOM + YPPUSH_RSRC = -3, /* Local resouce alloc failure */ +#define YPPUSH_RSRC YPPUSH_RSRC + YPPUSH_RPC = -4, /* RPC failure talking to server */ +#define YPPUSH_RPC YPPUSH_RPC + YPPUSH_MADDR = -5, /* Can't get master address */ +#define YPPUSH_MADDR YPPUSH_MADDR + YPPUSH_YPERR = -6, /* NIS server/map db error */ +#define YPPUSH_YPERR YPPUSH_YPERR + YPPUSH_BADARGS = -7, /* Request arguments bad */ +#define YPPUSH_BADARGS YPPUSH_BADARGS + YPPUSH_DBM = -8, /* Local dbm operation failed */ +#define YPPUSH_DBM YPPUSH_DBM + YPPUSH_FILE = -9, /* Local file I/O operation failed */ +#define YPPUSH_FILE YPPUSH_FILE + YPPUSH_SKEW = -10, /* Map version skew during transfer */ +#define YPPUSH_SKEW YPPUSH_SKEW + YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ +#define YPPUSH_CLEAR YPPUSH_CLEAR + YPPUSH_FORCE = -12, /* No local order number in map - use -f flag*/ +#define YPPUSH_FORCE YPPUSH_FORCE + YPPUSH_XFRERR = -13, /* ypxfr error */ +#define YPPUSH_XFRERR YPPUSH_XFRERR + YPPUSH_REFUSED = -14, /* Transfer request refused by ypserv */ +#define YPPUSH_REFUSED YPPUSH_REFUSED + YPPUSH_NOALIAS = -15 /* Alias not found for map or domain */ +#define YPPUSH_NOALIAS YPPUSH_NOALIAS +}; +typedef enum yppush_status yppush_status; + +struct yppushresp_xfr { + u_int transid; + yppush_status status; +}; +typedef struct yppushresp_xfr yppushresp_xfr; + +struct ypresp_all { + bool_t more; + union { + struct ypresp_key_val val; + } ypresp_all_u; +}; +typedef struct ypresp_all ypresp_all; + +extern bool_t xdr_domainname (XDR *__xdrs, char ** __objp); +extern bool_t xdr_keydat (XDR *__xdrs, keydat_t *__objp); +extern bool_t xdr_valdat (XDR *__xdrs, valdat_t *__objp); +extern bool_t xdr_ypall (XDR *__xdrs, struct ypall_callback * __objp); +extern bool_t xdr_ypbind2_binding (XDR *__xdrs, struct ypbind2_binding * __objp); +extern bool_t xdr_ypbind2_resp (XDR *__xdrs, struct ypbind2_resp * __objp); +extern bool_t xdr_ypbind2_setdom (XDR *__xdrs, struct ypbind2_setdom * __objp); +extern bool_t xdr_ypbind3_binding (XDR *__xdrs, struct ypbind3_binding * __objp); +extern bool_t xdr_ypbind3_resp (XDR *__xdrs, struct ypbind3_resp * __objp); +extern bool_t xdr_ypbind3_setdom (XDR *__xdrs, struct ypbind3_setdom * __objp); +extern bool_t xdr_ypbind_oldsetdom (XDR *__xdrs, struct ypbind_oldsetdom * __objp); +extern bool_t xdr_ypbind_resptype (XDR *__xdrs, enum ypbind_resptype * __objp); +extern bool_t xdr_ypmap_parms (XDR *__xdrs, struct ypmap_parms * __objp); +extern bool_t xdr_ypmaplist (XDR *__xdrs, struct ypmaplist *__objp); +extern bool_t xdr_yppushresp_xfr (XDR *__xdrs, struct yppushresp_xfr * __objp); +extern bool_t xdr_ypreq_key (XDR *__xdrs, struct ypreq_key * __objp); +extern bool_t xdr_ypreq_newxfr (XDR *__xdrs, struct ypreq_newxfr * __objp); +extern bool_t xdr_ypreq_nokey (XDR *__xdrs, struct ypreq_nokey * __objp); +extern bool_t xdr_ypreq_xfr (XDR *__xdrs, struct ypreq_xfr * __objp); +extern bool_t xdr_ypresp_all (XDR *__xdrs, struct ypresp_all * __objp); +extern bool_t xdr_ypresp_key_val (XDR *__xdrs, struct ypresp_key_val * __objp); +extern bool_t xdr_ypresp_maplist (XDR *__xdrs, struct ypresp_maplist * __objp); +extern bool_t xdr_ypresp_master (XDR *__xdrs, struct ypresp_master * __objp); +extern bool_t xdr_ypresp_order (XDR *__xdrs, struct ypresp_order * __objp); +extern bool_t xdr_ypresp_val (XDR *__xdrs, struct ypresp_val * __objp); +extern bool_t xdr_ypresp_xfr (XDR *__xdrs, struct ypresp_xfr *__objp); +extern bool_t xdr_ypstat (XDR *__xdrs, enum ypstat * __objp); +extern bool_t xdr_ypxfrstat (XDR *__xdrs, enum ypxfrstat *__objp); + +/* Not really for this, but missing better place: */ +extern const char *taddr2host (const struct netconfig *__nconf, + const struct netbuf *__nbuf, + char *__host, size_t __hostlen); +extern const char *taddr2ipstr (const struct netconfig *__nconf, + const struct netbuf *__nbuf, + char *__buf, size_t __buflen); +extern unsigned short taddr2port (const struct netconfig *__nconf, + const struct netbuf *__nbuf); + +#ifdef __cplusplus +} +#endif + + +#endif /* _RPCSVC_YP_PROT_H */ diff --git a/src/rpcsvc/ypclnt.h b/src/rpcsvc/ypclnt.h new file mode 100644 index 0000000..e6dc52c --- /dev/null +++ b/src/rpcsvc/ypclnt.h @@ -0,0 +1,91 @@ +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1996. + + The GNU C 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. + + The GNU C 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 the GNU C Library; if not, see + . */ + + +#ifndef __RPCSVC_YPCLNT_H__ +#define __RPCSVC_YPCLNT_H__ + +/* Some defines */ +#define YPERR_SUCCESS 0 /* There is no error */ +#define YPERR_BADARGS 1 /* Args to function are bad */ +#define YPERR_RPC 2 /* RPC failure */ +#define YPERR_DOMAIN 3 /* Can't bind to a server with this domain */ +#define YPERR_MAP 4 /* No such map in server's domain */ +#define YPERR_KEY 5 /* No such key in map */ +#define YPERR_YPERR 6 /* Internal yp server or client error */ +#define YPERR_RESRC 7 /* Local resource allocation failure */ +#define YPERR_NOMORE 8 /* No more records in map database */ +#define YPERR_PMAP 9 /* Can't communicate with portmapper */ +#define YPERR_YPBIND 10 /* Can't communicate with ypbind */ +#define YPERR_YPSERV 11 /* Can't communicate with ypserv */ +#define YPERR_NODOM 12 /* Local domain name not set */ +#define YPERR_BADDB 13 /* yp data base is bad */ +#define YPERR_VERS 14 /* YP version mismatch */ +#define YPERR_ACCESS 15 /* Access violation */ +#define YPERR_BUSY 16 /* Database is busy */ + +/* Types of update operations */ +#define YPOP_CHANGE 1 /* Change, do not add */ +#define YPOP_INSERT 2 /* Add, do not change */ +#define YPOP_DELETE 3 /* Delete this entry */ +#define YPOP_STORE 4 /* Add, or change */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* struct ypall_callback * is the arg which must be passed to yp_all. */ +struct ypall_callback + { + int (*foreach) (int __status, char *__key, int __keylen, + char *__val, int __vallen, char *__data); + char *data; + }; + +/* External NIS client function references. */ +extern int yp_bind (const char *); +extern void yp_unbind (const char *); +extern int yp_get_default_domain (char **); +extern int yp_match (const char *, const char *, const char *, + const int, char **, int *); +extern int yp_first (const char *, const char *, char **, + int *, char **, int *); +extern int yp_next (const char *, const char *, const char *, + const int, char **, int *, char **, int *); +extern int yp_master (const char *, const char *, char **); +extern int yp_order (const char *, const char *, unsigned int *); +extern int yp_all (const char *, const char *, + const struct ypall_callback *); +extern const char *yperr_string (const int); +extern const char *ypbinderr_string (const int); +extern int ypprot_err (const int); +extern int yp_update (char *, char *, unsigned int, char *, + int, char *, int); + +#if 0 +extern int yp_maplist (const char *, struct ypmaplist **); +#endif + +/* This functions exists only under BSD and Linux systems. */ +extern int __yp_check (char **); + +#ifdef __cplusplus +} +#endif + +#endif /* __RPCSVC_YPCLNT_H__ */ diff --git a/src/rpcsvc/yppasswd.h b/src/rpcsvc/yppasswd.h new file mode 100644 index 0000000..2d2a203 --- /dev/null +++ b/src/rpcsvc/yppasswd.h @@ -0,0 +1,49 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _YPPASSWD_H_RPCGEN +#define _YPPASSWD_H_RPCGEN + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +struct passwd { + char *pw_name; + char *pw_passwd; + int pw_uid; + int pw_gid; + char *pw_gecos; + char *pw_dir; + char *pw_shell; +}; +typedef struct passwd passwd; + +struct yppasswd { + char *oldpass; + struct passwd newpw; +}; +typedef struct yppasswd yppasswd; + +#define YPPASSWDPROG 100009 +#define YPPASSWDVERS 1 +#define YPPASSWDPROC_UPDATE 1 + +extern int * yppasswdproc_update_1(yppasswd *, CLIENT *); +extern int * yppasswdproc_update_1_svc(yppasswd *, struct svc_req *); +extern int yppasswdprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); + +/* the xdr functions */ +extern bool_t xdr_passwd (XDR *, struct passwd*); +extern bool_t xdr_yppasswd (XDR *, yppasswd*); + +#ifdef __cplusplus +} +#endif + +#endif /* !_YPPASSWD_H_RPCGEN */ diff --git a/src/rpcsvc/yppasswd.x b/src/rpcsvc/yppasswd.x new file mode 100644 index 0000000..34e3efe --- /dev/null +++ b/src/rpcsvc/yppasswd.x @@ -0,0 +1,61 @@ +/* @(#)yppasswd.x 2.1 88/08/01 4.0 RPCSRC */ + +/* + * Copyright (c) 2010, Oracle America, Inc. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of the "Oracle America, Inc." nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT HOLDER OR CONTRIBUTORS 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. + */ + +/* + * YP password update protocol + * Requires unix authentication + */ +program YPPASSWDPROG { + version YPPASSWDVERS { + /* + * Update my passwd entry + */ + int + YPPASSWDPROC_UPDATE(yppasswd) = 1; + } = 1; +} = 100009; + + +struct passwd { + string pw_name<>; /* username */ + string pw_passwd<>; /* encrypted password */ + int pw_uid; /* user id */ + int pw_gid; /* group id */ + string pw_gecos<>; /* in real life name */ + string pw_dir<>; /* home directory */ + string pw_shell<>; /* default shell */ +}; + +struct yppasswd { + string oldpass<>; /* unencrypted old password */ + passwd newpw; /* new passwd entry */ +}; diff --git a/src/rpcsvc/ypupd.h b/src/rpcsvc/ypupd.h new file mode 100644 index 0000000..64f8d87 --- /dev/null +++ b/src/rpcsvc/ypupd.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2010, Oracle America, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of the "Oracle America, Inc." nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT HOLDER OR CONTRIBUTORS 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. + */ +/* from @(#)ypupdate_prot.x 1.3 91/03/11 TIRPC 1.0 */ + +#ifndef __RPCSVC_YPUPD_H__ +#define __RPCSVC_YPUPD_H__ + +#include + +#define MAXMAPNAMELEN 255 +#define MAXYPDATALEN 1023 +#define MAXERRMSGLEN 255 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + u_int yp_buf_len; + char *yp_buf_val; +} yp_buf; + +extern bool_t xdr_yp_buf (XDR *, yp_buf*); + +struct ypupdate_args { + char *mapname; + yp_buf key; + yp_buf datum; +}; +typedef struct ypupdate_args ypupdate_args; + +extern bool_t xdr_ypupdate_args (XDR *, ypupdate_args*); + +struct ypdelete_args { + char *mapname; + yp_buf key; +}; +typedef struct ypdelete_args ypdelete_args; + +extern bool_t xdr_ypdelete_args (XDR *, ypdelete_args*); + +#define YPU_PROG 100028 +#define YPU_VERS 1 + +#define YPU_CHANGE 1 +extern u_int * ypu_change_1 (ypupdate_args *, CLIENT *); +extern u_int * ypu_change_1_svc (ypupdate_args *, struct svc_req *); +#define YPU_INSERT 2 +extern u_int * ypu_insert_1 (ypupdate_args *, CLIENT *); +extern u_int * ypu_insert_1_svc (ypupdate_args *, struct svc_req *); +#define YPU_DELETE 3 +extern u_int * ypu_delete_1 (ypdelete_args *, CLIENT *); +extern u_int * ypu_delete_1_svc (ypdelete_args *, struct svc_req *); +#define YPU_STORE 4 +extern u_int * ypu_store_1 (ypupdate_args *, CLIENT *); +extern u_int * ypu_store_1_svc (ypupdate_args *, struct svc_req *); + +#ifdef __cplusplus +} +#endif + +#endif /* !__RPCSVC_YPUPD_H__ */ diff --git a/src/taddr2host.c b/src/taddr2host.c new file mode 100644 index 0000000..c1541a9 --- /dev/null +++ b/src/taddr2host.c @@ -0,0 +1,73 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#if defined(HAVE_TIRPC) + +#include +#include +#include + +#include "internal.h" + +const char * +taddr2host (const struct netconfig *nconf, const struct netbuf *nbuf, + char *host, size_t hostlen) +{ + int error; + struct __rpc_sockinfo si; + struct sockaddr_in *sin; + struct sockaddr_in6 *sin6; + + if (nconf == NULL || nbuf == NULL || nbuf->len <= 0) + return NULL; + + if (!__rpc_nconf2sockinfo (nconf, &si)) + return NULL; + + switch (si.si_af) { + case AF_INET: + sin = nbuf->buf; + sin->sin_family = si.si_af; + error = getnameinfo((struct sockaddr *)sin, + sizeof (struct sockaddr_in), + host, hostlen, NULL, 0, 0); + if (error) + fprintf (stderr, "getnameinfo(): %s\n", gai_strerror(error)); + break; + case AF_INET6: + sin6 = nbuf->buf; + sin6->sin6_family = si.si_af; + error = getnameinfo((struct sockaddr *)sin6, + sizeof (struct sockaddr_in6), + host, hostlen, NULL, 0, 0); + if (error) + fprintf (stderr, "getnameinfo(): %s\n", gai_strerror(error)); + break; + default: + error = 1; + break; + } + + if (error) + return NULL; + else + return host; +} + +#endif diff --git a/src/taddr2ipstr.c b/src/taddr2ipstr.c new file mode 100644 index 0000000..533a655 --- /dev/null +++ b/src/taddr2ipstr.c @@ -0,0 +1,75 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#if defined(HAVE_TIRPC) + +#include +#include +#include +#include +#include + +#include "internal.h" + +const char * +taddr2ipstr (const struct netconfig *nconf, const struct netbuf *nbuf, + char *buf, size_t buflen) +{ + struct __rpc_sockinfo si; + struct sockaddr_in *sin; + struct sockaddr_in6 *sin6; + struct sockaddr_un *sun; + + if (nconf == NULL || nbuf == NULL || nbuf->len <= 0) + return NULL; + + if (!__rpc_nconf2sockinfo(nconf, &si)) + return NULL; + + switch (si.si_af) + { + case AF_INET: + sin = nbuf->buf; + if (inet_ntop(si.si_af, &sin->sin_addr, buf, buflen) == NULL) + return NULL; + break; + case AF_INET6: + sin6 = nbuf->buf; + if (inet_ntop(si.si_af, &sin6->sin6_addr, buf, buflen) == NULL) + return NULL; + break; + case AF_LOCAL: + sun = nbuf->buf; + /* if (asprintf(&ret, "%.*s", (int)(sun->sun_len - + offsetof(struct sockaddr_un, sun_path)), + sun->sun_path) < 0)*/ + if (snprintf (buf, buflen, "%.*s", (int)(sizeof(*sun) - + offsetof(struct sockaddr_un, sun_path)), + sun->sun_path) < 0) + return NULL; + break; + default: + return NULL; + break; + } + + return buf; +} + +#endif /* HAVE_TIRPC */ diff --git a/src/taddr2port.c b/src/taddr2port.c new file mode 100644 index 0000000..ea5ea95 --- /dev/null +++ b/src/taddr2port.c @@ -0,0 +1,60 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#if defined(HAVE_TIRPC) + +#include +#include +#include +#include + +#include "internal.h" + +unsigned short +taddr2port (const struct netconfig *nconf, const struct netbuf *nbuf) +{ + unsigned short port = 0; + struct __rpc_sockinfo si; + struct sockaddr_in *sin; + struct sockaddr_in6 *sin6; + + if (nconf == NULL || nbuf == NULL || nbuf->len <= 0) + return 0; + + if (!__rpc_nconf2sockinfo(nconf, &si)) + return 0; + + switch (si.si_af) + { + case AF_INET: + sin = nbuf->buf; + port = sin->sin_port; + break; + case AF_INET6: + sin6 = nbuf->buf; + port = sin6->sin6_port; + break; + default: + break; + } + + return htons (port); +} + +#endif diff --git a/src/yp_first.c b/src/yp_first.c new file mode 100644 index 0000000..3adf9c5 --- /dev/null +++ b/src/yp_first.c @@ -0,0 +1,78 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "internal.h" + +int +yp_first (const char *indomain, const char *inmap, char **outkey, + int *outkeylen, char **outval, int *outvallen) +{ + ypreq_nokey req; + ypresp_key_val resp; + enum clnt_stat result; + + if (indomain == NULL || indomain[0] == '\0' || + inmap == NULL || inmap[0] == '\0') + return YPERR_BADARGS; + + req.domain = (char *) indomain; + req.map = (char *) inmap; + + *outkey = *outval = NULL; + *outkeylen = *outvallen = 0; + memset (&resp, '\0', sizeof (resp)); + + result = do_ypcall (indomain, YPPROC_FIRST, (xdrproc_t) xdr_ypreq_nokey, + (caddr_t) &req, (xdrproc_t) xdr_ypresp_key_val, + (caddr_t) &resp); + + if (result != RPC_SUCCESS) + return YPERR_RPC; + if (resp.status != YP_TRUE) + return ypprot_err (resp.status); + + int status; + if ((*outkey = malloc (resp.keydat.keydat_len + 1)) != NULL && + (*outval = malloc (resp.valdat.valdat_len + 1)) != NULL) + { + *outkeylen = resp.keydat.keydat_len; + memcpy (*outkey, resp.keydat.keydat_val, *outkeylen); + (*outkey)[*outkeylen] = '\0'; + + *outvallen = resp.valdat.valdat_len; + memcpy (*outval, resp.valdat.valdat_val, *outvallen); + (*outval)[*outvallen] = '\0'; + + status = YPERR_SUCCESS; + } + else + { + free (*outkey); + status = YPERR_RESRC; + } + + xdr_free ((xdrproc_t) xdr_ypresp_key_val, (char *) &resp); + + return status; +} diff --git a/src/yp_get_default_domain.c b/src/yp_get_default_domain.c new file mode 100644 index 0000000..dbd83a9 --- /dev/null +++ b/src/yp_get_default_domain.c @@ -0,0 +1,58 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "libc-lock.h" + +__libc_lock_define_initialized (static, domainname_lock) +static char ypdomainname[NIS_MAXNAMELEN + 1]; + +int +yp_get_default_domain (char **outdomain) +{ + int result = YPERR_SUCCESS;; + *outdomain = NULL; + + __libc_lock_lock (domainname_lock); + + if (ypdomainname[0] == '\0') + { + if (getdomainname (ypdomainname, NIS_MAXNAMELEN)) + result = YPERR_NODOM; + else if (strcmp (ypdomainname, "(none)") == 0) + { + /* If domainname is not set, some systems will return "(none)" */ + ypdomainname[0] = '\0'; + result = YPERR_NODOM; + } + else + *outdomain = ypdomainname; + } + else + *outdomain = ypdomainname; + + __libc_lock_unlock (domainname_lock); + + return result; +} diff --git a/src/yp_maplist.c b/src/yp_maplist.c new file mode 100644 index 0000000..754e467 --- /dev/null +++ b/src/yp_maplist.c @@ -0,0 +1,49 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include "internal.h" + +int +yp_maplist (const char *indomain, struct ypmaplist **outmaplist) +{ + struct ypresp_maplist resp; + enum clnt_stat result; + + if (indomain == NULL || indomain[0] == '\0') + return YPERR_BADARGS; + + memset (&resp, '\0', sizeof (resp)); + + result = do_ypcall_tr (indomain, YPPROC_MAPLIST, (xdrproc_t) xdr_domainname, + (caddr_t) &indomain, (xdrproc_t) xdr_ypresp_maplist, + (ypresp_val *) &resp); + + if (result == YPERR_SUCCESS) + { + *outmaplist = resp.list; + /* We don't free the list, this will be done by ypserv + xdr_free((xdrproc_t)xdr_ypresp_maplist, (char *)&resp); */ + } + + return result; +} diff --git a/src/yp_master.c b/src/yp_master.c new file mode 100644 index 0000000..4c6cf6c --- /dev/null +++ b/src/yp_master.c @@ -0,0 +1,54 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "internal.h" + +int +yp_master (const char *indomain, const char *inmap, char **outname) +{ + struct ypreq_nokey req; + struct ypresp_master resp; + enum clnt_stat result; + + if (indomain == NULL || indomain[0] == '\0' || + inmap == NULL || inmap[0] == '\0') + return YPERR_BADARGS; + + req.domain = (char *) indomain; + req.map = (char *) inmap; + + memset (&resp, '\0', sizeof (struct ypresp_master)); + + result = do_ypcall_tr (indomain, YPPROC_MASTER, (xdrproc_t) xdr_ypreq_nokey, + (caddr_t) &req, (xdrproc_t) xdr_ypresp_master, + (ypresp_val *) &resp); + + if (result != YPERR_SUCCESS) + return result; + + *outname = strdup (resp.master); + xdr_free ((xdrproc_t) xdr_ypresp_master, (char *) &resp); + + return *outname == NULL ? YPERR_YPERR : YPERR_SUCCESS; +} diff --git a/src/yp_match.c b/src/yp_match.c new file mode 100644 index 0000000..603892d --- /dev/null +++ b/src/yp_match.c @@ -0,0 +1,68 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include "internal.h" + +int +yp_match (const char *indomain, const char *inmap, const char *inkey, + const int inkeylen, char **outval, int *outvallen) +{ + ypreq_key req; + ypresp_val resp; + enum clnt_stat result; + + if (indomain == NULL || indomain[0] == '\0' || + inmap == NULL || inmap[0] == '\0' || + inkey == NULL || inkey[0] == '\0' || inkeylen <= 0) + return YPERR_BADARGS; + + req.domain = (char *) indomain; + req.map = (char *) inmap; + req.keydat.keydat_val = (char *) inkey; + req.keydat.keydat_len = inkeylen; + + *outval = NULL; + *outvallen = 0; + memset (&resp, '\0', sizeof (resp)); + + result = do_ypcall_tr (indomain, YPPROC_MATCH, (xdrproc_t) xdr_ypreq_key, + (caddr_t) &req, (xdrproc_t) xdr_ypresp_val, + (ypresp_val *) &resp); + + if (result != YPERR_SUCCESS) + return result; + + *outvallen = resp.valdat.valdat_len; + *outval = malloc (*outvallen + 1); + int status = YPERR_RESRC; + if (*outval != NULL) + { + memcpy (*outval, resp.valdat.valdat_val, *outvallen); + (*outval)[*outvallen] = '\0'; + status = YPERR_SUCCESS; + } + + xdr_free ((xdrproc_t) xdr_ypresp_val, (char *) &resp); + + return status; +} diff --git a/src/yp_next.c b/src/yp_next.c new file mode 100644 index 0000000..f9b60fd --- /dev/null +++ b/src/yp_next.c @@ -0,0 +1,80 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "internal.h" + +int +yp_next (const char *indomain, const char *inmap, const char *inkey, + const int inkeylen, char **outkey, int *outkeylen, char **outval, + int *outvallen) +{ + ypreq_key req; + ypresp_key_val resp; + enum clnt_stat result; + + if (indomain == NULL || indomain[0] == '\0' || + inmap == NULL || inmap[0] == '\0' || + inkeylen <= 0 || inkey == NULL || inkey[0] == '\0') + return YPERR_BADARGS; + + req.domain = (char *) indomain; + req.map = (char *) inmap; + req.keydat.keydat_val = (char *) inkey; + req.keydat.keydat_len = inkeylen; + + *outkey = *outval = NULL; + *outkeylen = *outvallen = 0; + memset (&resp, '\0', sizeof (resp)); + + result = do_ypcall_tr (indomain, YPPROC_NEXT, (xdrproc_t) xdr_ypreq_key, + (caddr_t) &req, (xdrproc_t) xdr_ypresp_key_val, + (ypresp_val *) &resp); + + if (result != YPERR_SUCCESS) + return result; + + int status; + if((*outkey = malloc (resp.keydat.keydat_len + 1)) != NULL && + (*outval = malloc (resp.valdat.valdat_len + 1)) != NULL) + { + *outkeylen = resp.keydat.keydat_len; + memcpy (*outkey, resp.keydat.keydat_val, *outkeylen); + (*outkey)[*outkeylen] = '\0'; + + *outvallen = resp.valdat.valdat_len; + memcpy (*outval, resp.valdat.valdat_val, *outvallen); + (*outval)[*outvallen] = '\0'; + + status = YPERR_SUCCESS; + } + else + { + free (*outkey); + status = YPERR_RESRC; + } + + xdr_free ((xdrproc_t) xdr_ypresp_key_val, (char *) &resp); + + return status; +} diff --git a/src/yp_order.c b/src/yp_order.c new file mode 100644 index 0000000..328c0af --- /dev/null +++ b/src/yp_order.c @@ -0,0 +1,52 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "internal.h" + +int +yp_order (const char *indomain, const char *inmap, unsigned int *outorder) +{ + struct ypreq_nokey req; + struct ypresp_order resp; + enum clnt_stat result; + + if (indomain == NULL || indomain[0] == '\0' || + inmap == NULL || inmap[0] == '\0') + return YPERR_BADARGS; + + req.domain = (char *) indomain; + req.map = (char *) inmap; + memset (&resp, '\0', sizeof (resp)); + result = do_ypcall_tr (indomain, YPPROC_ORDER, (xdrproc_t) xdr_ypreq_nokey, + (caddr_t) &req, (xdrproc_t) xdr_ypresp_order, + (ypresp_val *) &resp); + + if (result != YPERR_SUCCESS) + return result; + + *outorder = resp.ordernum; + xdr_free ((xdrproc_t) xdr_ypresp_order, (char *) &resp); + + return result; +} diff --git a/src/yp_xdr.c b/src/yp_xdr.c new file mode 100644 index 0000000..8938dd9 --- /dev/null +++ b/src/yp_xdr.c @@ -0,0 +1,441 @@ +/* Modified and extended by Thorsten Kukuk , 2016 */ +/* + * Copyright (c) 2010, Oracle America, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of the "Oracle America, Inc." nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT HOLDER OR CONTRIBUTORS 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#if defined(HAVE_TIRPC) +#include +#endif +#include +#include +#include +#include +#include + +/* The NIS v2 protocol suggests 1024 bytes as a maximum length of all fields. + Current Linux systems don't use this limit. To remain compatible with + recent Linux systems we choose limits large enough to load large key and + data values, but small enough to not pose a DoS threat. */ + +#define XDRMAXNAME 1024 +#define XDRMAXRECORD (16 * 1024 * 1024) + +bool_t +xdr_ypstat (XDR *xdrs, ypstat *objp) +{ + return xdr_enum (xdrs, (enum_t *) objp); +} + +bool_t +xdr_ypxfrstat(XDR *xdrs, ypxfrstat *objp) +{ + return xdr_enum(xdrs, (enum_t *)objp); +} + +bool_t +xdr_domainname (XDR *xdrs, char **objp) +{ + return xdr_string (xdrs, objp, XDRMAXNAME); +} + +bool_t +xdr_keydat (XDR *xdrs, keydat_t *objp) +{ + return xdr_bytes (xdrs, (char **) &objp->keydat_val, + (u_int *) &objp->keydat_len, XDRMAXRECORD); +} + +bool_t +xdr_valdat (XDR *xdrs, valdat_t *objp) +{ + return xdr_bytes (xdrs, (char **) &objp->valdat_val, + (u_int *) &objp->valdat_len, XDRMAXRECORD); +} + +bool_t +xdr_ypmap_parms (XDR *xdrs, struct ypmap_parms *objp) +{ + if (!xdr_domainname (xdrs, &objp->domain)) + return FALSE; + if (!xdr_string (xdrs, &objp->map, XDRMAXNAME)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->ordernum)) + return FALSE; + return xdr_string (xdrs, &objp->owner, XDRMAXNAME); +} + +bool_t +xdr_ypreq_key (XDR *xdrs, struct ypreq_key *objp) +{ + if (!xdr_domainname (xdrs, &objp->domain)) + return FALSE; + if (!xdr_string (xdrs, &objp->map, XDRMAXNAME)) + return FALSE; + return xdr_keydat (xdrs, &objp->keydat); +} + +bool_t +xdr_ypreq_nokey (XDR *xdrs, struct ypreq_nokey *objp) +{ + if (!xdr_domainname (xdrs, &objp->domain)) + return FALSE; + return xdr_string (xdrs, &objp->map, XDRMAXNAME); +} + +bool_t +xdr_ypreq_xfr (XDR *xdrs, struct ypreq_xfr *objp) +{ + if (!xdr_ypmap_parms (xdrs, &objp->map_parms)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->transid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->proto)) + return FALSE; + return xdr_u_int (xdrs, &objp->port); +} + +bool_t +xdr_ypreq_newxfr (XDR *xdrs, struct ypreq_newxfr *objp) +{ + if (!xdr_ypmap_parms (xdrs, &objp->map_parms)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->transid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->proto)) + return FALSE; + return xdr_string (xdrs, &objp->name, XDRMAXNAME); +} + +bool_t +xdr_ypresp_val (XDR *xdrs, struct ypresp_val *objp) +{ + if (!xdr_ypstat (xdrs, &objp->status)) + return FALSE; + return xdr_valdat (xdrs, &objp->valdat); +} + +bool_t +xdr_ypresp_key_val (XDR *xdrs, struct ypresp_key_val *objp) +{ + if (!xdr_ypstat (xdrs, &objp->status)) + return FALSE; + if (!xdr_valdat (xdrs, &objp->valdat)) + return FALSE; + return xdr_keydat (xdrs, &objp->keydat); +} + +bool_t +xdr_ypresp_master (XDR *xdrs, struct ypresp_master *objp) +{ + if (!xdr_ypstat (xdrs, &objp->status)) + return FALSE; + return xdr_string (xdrs, &objp->master, XDRMAXNAME); +} + +bool_t +xdr_ypresp_order (XDR *xdrs, struct ypresp_order *objp) +{ + if (!xdr_ypstat (xdrs, &objp->status)) + return FALSE; + return xdr_u_int (xdrs, &objp->ordernum); +} + +bool_t +xdr_ypresp_xfr (XDR *xdrs, ypresp_xfr *objp) +{ + if (!xdr_u_int(xdrs, &objp->transid)) + return FALSE; + + if (!xdr_ypxfrstat(xdrs, &objp->xfrstat)) + return FALSE; + + return TRUE; +} + +bool_t +xdr_ypresp_all (XDR *xdrs, struct ypresp_all *objp) +{ + if (!xdr_bool (xdrs, &objp->more)) + return FALSE; + switch (objp->more) + { + case TRUE: + return xdr_ypresp_key_val (xdrs, &objp->ypresp_all_u.val); + case FALSE: + break; + default: + return FALSE; + } + return TRUE; +} + +bool_t +xdr_ypmaplist (XDR *xdrs, struct ypmaplist *objp) +{ + char **tp; + if (!xdr_string (xdrs, &objp->map, XDRMAXNAME)) + return FALSE; + /* Prevent gcc warning about alias violation. */ + tp = (void *) &objp->next; + return xdr_pointer (xdrs, tp, sizeof (struct ypmaplist), + (xdrproc_t) xdr_ypmaplist); +} + +bool_t +xdr_ypresp_maplist (XDR *xdrs, struct ypresp_maplist *objp) +{ + char **tp; + if (!xdr_ypstat (xdrs, &objp->status)) + return FALSE; + /* Prevent gcc warning about alias violation. */ + tp = (void *) &objp->list; + return xdr_pointer (xdrs, tp, sizeof (struct ypmaplist), + (xdrproc_t) xdr_ypmaplist); +} + +static bool_t +xdr_yppush_status (XDR *xdrs, enum yppush_status *objp) +{ + return xdr_enum (xdrs, (enum_t *) objp); +} + +bool_t +xdr_yppushresp_xfr (XDR *xdrs, struct yppushresp_xfr *objp) +{ + if (!xdr_u_int (xdrs, &objp->transid)) + return FALSE; + return xdr_yppush_status (xdrs, &objp->status); +} + +bool_t +xdr_ypbind_resptype (XDR *xdrs, enum ypbind_resptype *objp) +{ + return xdr_enum (xdrs, (enum_t *) objp); +} + +bool_t +xdr_ypbind2_binding (XDR *xdrs, struct ypbind2_binding *objp) +{ + if (!xdr_opaque (xdrs, (char *)&objp->ypbind_binding_addr, 4)) + return FALSE; + return xdr_opaque (xdrs, (char *)&objp->ypbind_binding_port, 2); +} + +bool_t +xdr_ypbind2_resp (XDR *xdrs, struct ypbind2_resp *objp) +{ + if (!xdr_ypbind_resptype (xdrs, &objp->ypbind_status)) + return FALSE; + switch (objp->ypbind_status) + { + case YPBIND_FAIL_VAL: + return xdr_u_int (xdrs, &objp->ypbind_respbody.ypbind_error); + case YPBIND_SUCC_VAL: + return xdr_ypbind2_binding (xdrs, &objp->ypbind_respbody.ypbind_bindinfo); + } + return FALSE; +} + +bool_t +xdr_ypbind_oldsetdom (XDR *xdrs, struct ypbind_oldsetdom *objp) +{ + if (!xdr_vector (xdrs, (char *)objp->ypoldsetdom_domain, YPMAXDOMAIN, + sizeof (char), (xdrproc_t) xdr_char)) + return FALSE; + if (!xdr_ypbind2_binding (xdrs, &objp->ypoldsetdom_binding)) + return FALSE; + return TRUE; +} + +bool_t +xdr_ypbind2_setdom (XDR *xdrs, struct ypbind2_setdom *objp) +{ + if (!xdr_domainname (xdrs, &objp->ypsetdom_domain)) + return FALSE; + if (!xdr_ypbind2_binding (xdrs, &objp->ypsetdom_binding)) + return FALSE; + return xdr_u_int (xdrs, &objp->ypsetdom_vers); +} + +#if defined(HAVE_TIRPC) +/* Same values in netconfig are u_long with TI-RPC on + Linux, but u_int on Solaris */ +static bool_t +xdr_fake_u_int (XDR *xdrs, unsigned long *objp) +{ + switch (xdrs->x_op) + { + case XDR_DECODE: + { + uint32_t tmp; + + if (!xdr_u_int (xdrs, &tmp)) + return FALSE; + *objp = tmp; + return TRUE; + } + case XDR_ENCODE: + { + uint32_t tmp = *objp; + + if (!xdr_u_int (xdrs, &tmp)) + return FALSE; + return TRUE; + } + case XDR_FREE: + return TRUE; + } + return FALSE; +} + + +static bool_t +xdr_netconfig (XDR *xdrs, struct netconfig *objp) +{ + if (!xdr_string(xdrs, &objp->nc_netid, ~0)) + return FALSE; + + if (!xdr_fake_u_int (xdrs, &objp->nc_semantics)) + return FALSE; + if (!xdr_fake_u_int (xdrs, &objp->nc_flag)) + return FALSE; + if (!xdr_string (xdrs, &objp->nc_protofmly, ~0)) + return FALSE; + if (!xdr_string (xdrs, &objp->nc_proto, ~0)) + return FALSE; + if (!xdr_string(xdrs, &objp->nc_device, ~0)) + return FALSE; + if (!xdr_array(xdrs, (char **)&objp->nc_lookups, + (uint32_t *)&objp->nc_nlookups, 100, sizeof (char *), + (xdrproc_t)xdr_wrapstring)) + return FALSE; + return xdr_vector (xdrs, (char *)objp->nc_unused, + 8, sizeof (uint32_t), (xdrproc_t)xdr_u_int); +} + + +bool_t +xdr_ypbind3_binding (XDR *xdrs, struct ypbind3_binding *objp) +{ + if (!xdr_pointer (xdrs, (char **)&objp->ypbind_nconf, + sizeof (struct netconfig), (xdrproc_t) xdr_netconfig)) + return FALSE; + if (!xdr_pointer(xdrs, (char **)&objp->ypbind_svcaddr, + sizeof (struct netbuf), (xdrproc_t) xdr_netbuf)) + return FALSE; + if (!xdr_string(xdrs, &objp->ypbind_servername, ~0)) + return FALSE; + if (!xdr_rpcvers(xdrs, &objp->ypbind_hi_vers)) + return FALSE; + return xdr_rpcvers(xdrs, &objp->ypbind_lo_vers); +} + + +bool_t +xdr_ypbind3_resp (XDR *xdrs, struct ypbind3_resp *objp) +{ + if (!xdr_ypbind_resptype(xdrs, &objp->ypbind_status)) + return FALSE; + switch (objp->ypbind_status) + { + case YPBIND_FAIL_VAL: + if (!xdr_fake_u_int(xdrs, &objp->ypbind_respbody.ypbind_error)) + return FALSE; + break; + case YPBIND_SUCC_VAL: + if (!xdr_pointer (xdrs, + (char **)&objp->ypbind_respbody.ypbind_bindinfo, + sizeof (struct ypbind3_binding), (xdrproc_t) xdr_ypbind3_binding)) + return FALSE; + break; + default: + return FALSE; + } + return TRUE; +} + +bool_t +xdr_ypbind3_setdom (XDR *xdrs, ypbind3_setdom *objp) +{ + if (!xdr_string (xdrs, &objp->ypsetdom_domain, YPMAXDOMAIN)) + return FALSE; + return xdr_pointer (xdrs, (char **)&objp->ypsetdom_bindinfo, + sizeof (struct ypbind3_binding), (xdrproc_t) xdr_ypbind3_binding); +} + +#endif /* HAVE_TIRPC */ + +bool_t +xdr_ypall(XDR *xdrs, struct ypall_callback *incallback) +{ + struct ypresp_key_val out; + char key[YPMAXRECORD], val[YPMAXRECORD]; + + /* + * Set up key/val struct to be used during the transaction. + */ + memset(&out, 0, sizeof out); + out.keydat.keydat_val = key; + out.keydat.keydat_len = sizeof(key); + out.valdat.valdat_val = val; + out.valdat.valdat_len = sizeof(val); + + for (;;) { + bool_t more, status; + + /* Values pending? */ + if (!xdr_bool(xdrs, &more)) + return FALSE; /* can't tell! */ + if (!more) + return TRUE; /* no more */ + + /* Transfer key/value pair. */ + status = xdr_ypresp_key_val(xdrs, &out); + + /* + * If we succeeded, call the callback function. + * The callback will return TRUE when it wants + * no more values. If we fail, indicate the + * error. + */ + if (status) { + if ((*incallback->foreach)(out.status, + (char *)out.keydat.keydat_val, out.keydat.keydat_len, + (char *)out.valdat.valdat_val, out.valdat.valdat_len, + incallback->data)) + return TRUE; + } else + return FALSE; + } +} diff --git a/src/ypbinderr_string.c b/src/ypbinderr_string.c new file mode 100644 index 0000000..cc57499 --- /dev/null +++ b/src/ypbinderr_string.c @@ -0,0 +1,61 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#ifndef _ +#define _(String) gettext (String) +#endif + +#ifndef N_ +#define N_(String) String +#endif + + +const char * +ypbinderr_string (const int error) +{ + const char *str; + switch (error) + { + case 0: + str = N_("Success"); + break; + case YPBIND_ERR_ERR: + str = N_("Internal ypbind error"); + break; + case YPBIND_ERR_NOSERV: + str = N_("Domain not bound"); + break; + case YPBIND_ERR_RESC: + str = N_("System resource allocation failure"); + break; + case YPBIND_ERR_NODOMAIN: + str = N_("Domain doesn't exist"); + break; + default: + str = N_("Unknown ypbind error"); + break; + } + return _(str); +} diff --git a/src/yperr_string.c b/src/yperr_string.c new file mode 100644 index 0000000..aeaef89 --- /dev/null +++ b/src/yperr_string.c @@ -0,0 +1,95 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#ifndef _ +#define _(String) gettext (String) +#endif + +#ifndef N_ +#define N_(String) String +#endif + +const char * +yperr_string (const int error) +{ + const char *str; + switch (error) + { + case YPERR_SUCCESS: + str = N_("Success"); + break; + case YPERR_BADARGS: + str = N_("Request arguments bad"); + break; + case YPERR_RPC: + str = N_("RPC failure on NIS operation"); + break; + case YPERR_DOMAIN: + str = N_("Can't bind to server which serves this domain"); + break; + case YPERR_MAP: + str = N_("No such map in server's domain"); + break; + case YPERR_KEY: + str = N_("No such key in map"); + break; + case YPERR_YPERR: + str = N_("Internal NIS error"); + break; + case YPERR_RESRC: + str = N_("Local resource allocation failure"); + break; + case YPERR_NOMORE: + str = N_("No more records in map database"); + break; + case YPERR_PMAP: + str = N_("Can't communicate with portmapper"); + break; + case YPERR_YPBIND: + str = N_("Can't communicate with ypbind"); + break; + case YPERR_YPSERV: + str = N_("Can't communicate with ypserv"); + break; + case YPERR_NODOM: + str = N_("Local domain name not set"); + break; + case YPERR_BADDB: + str = N_("NIS map database is bad"); + break; + case YPERR_VERS: + str = N_("NIS client/server version mismatch - can't supply service"); + break; + case YPERR_ACCESS: + str = N_("Permission denied"); + break; + case YPERR_BUSY: + str = N_("Database is busy"); + break; + default: + str = N_("Unknown NIS error code"); + break; + } + return _(str); +} diff --git a/src/ypprot_err.c b/src/ypprot_err.c new file mode 100644 index 0000000..dac2071 --- /dev/null +++ b/src/ypprot_err.c @@ -0,0 +1,46 @@ +/* Copyright (C) 2014 Thorsten Kukuk + Author: Thorsten Kukuk + + This library is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + in version 2.1 as published by the Free Software Foundation. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +static const int8_t yp_2_yperr[] = + { +#define YP2YPERR(yp, yperr) [YP_##yp - YP_VERS] = YPERR_##yperr + YP2YPERR (TRUE, SUCCESS), + YP2YPERR (NOMORE, NOMORE), + YP2YPERR (FALSE, YPERR), + YP2YPERR (NOMAP, MAP), + YP2YPERR (NODOM, DOMAIN), + YP2YPERR (NOKEY, KEY), + YP2YPERR (BADOP, YPERR), + YP2YPERR (BADDB, BADDB), + YP2YPERR (YPERR, YPERR), + YP2YPERR (BADARGS, BADARGS), + YP2YPERR (VERS, VERS) + }; + +int +ypprot_err (const int code) +{ + if (code < YP_VERS || code > YP_NOMORE) + return YPERR_YPERR; + return yp_2_yperr[code - YP_VERS]; +}