--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+ <HEAD>
+ <TITLE> [IRCServices Coding] Migrating Modules to 5.1...
+ </TITLE>
+ <LINK REL="Index" HREF="index.html" >
+ <LINK REL="made" HREF="mailto:ircservices-coding%40ircservices.za.net?Subject=%5BIRCServices%20Coding%5D%20Migrating%20Modules%20to%205.1...&In-Reply-To=48AB0288.7060600%40webspace.ms">
+ <META NAME="robots" CONTENT="index,nofollow">
+ <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
+ <LINK REL="Previous" HREF="003323.html">
+ <LINK REL="Next" HREF="003325.html">
+ </HEAD>
+ <BODY BGCOLOR="#ffffff">
+ <H1>[IRCServices Coding] Migrating Modules to 5.1...</H1>
+ <B>Andrew Church</B>
+ <A HREF="mailto:ircservices-coding%40ircservices.za.net?Subject=%5BIRCServices%20Coding%5D%20Migrating%20Modules%20to%205.1...&In-Reply-To=48AB0288.7060600%40webspace.ms"
+ TITLE="[IRCServices Coding] Migrating Modules to 5.1...">achurch at achurch.org
+ </A><BR>
+ <I>Wed Aug 20 11:20:26 PDT 2008</I>
+ <P><UL>
+ <LI>Previous message: <A HREF="003323.html">[IRCServices Coding] Migrating Modules to 5.1...
+</A></li>
+ <LI>Next message: <A HREF="003325.html">[IRCServices Coding] [IRCServices] akick not setting channel ban
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#3324">[ date ]</a>
+ <a href="thread.html#3324">[ thread ]</a>
+ <a href="subject.html#3324">[ subject ]</a>
+ <a href="author.html#3324">[ author ]</a>
+ </LI>
+ </UL>
+ <HR>
+<!--beginarticle-->
+<PRE>To extract from a Password structure (assuming the source password buffer
+is declared as "Password source_password"):
+
+ char password_buffer[PASSMAX];
+ char *cipher;
+ memcpy(password_buffer, source_password.password, PASSMAX);
+ cipher = strdup(source_password.cipher);
+
+To copy into a Password structure (assuming the target password buffer is
+declared as "Password target_password" and the data to be copied is in
+"password_buffer" and "cipher" variables as above):
+
+ Password temp_password;
+ init_password(&temp_password);
+ memcpy(temp_password.password, password_buffer, PASSMAX);
+ temp_password.cipher = cipher;
+ copy_password(&target_password, &temp_password);
+ // Don't leave a copy of the password in memory
+ memset(&temp_password, 0, sizeof(temp_password));
+ memset(password_buffer, 0, PASSMAX);
+
+I actually think I'll add a set_password() function to simplify this, so
+the above would then become simply:
+
+ set_password(&target_password, password_buffer, cipher);
+ // Don't leave a copy of the password in memory
+ memset(password_buffer, 0, PASSMAX);
+
+See the "encrypt.h" header file and section 2-9-1 of the technical manual
+for further details.
+
+ --Andrew Church
+ <A HREF="http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding">achurch at achurch.org</A>
+ <A HREF="http://achurch.org/">http://achurch.org/</A>
+
+><i>Hy,
+</I>><i>
+</I>><i>Would that be the right way?:
+</I>><i>
+</I>><i>copy_password(&ngi->pass, &passbuf);
+</I>><i>strncpy(&passbuf, row[field(MYSQL_FIELD_USERINFO_PASSWORD) ...
+</I>><i>
+</I>><i>Are there sample codes to use copy_password in the right way?
+</I>><i>
+</I>><i>Regards.
+</I>><i>
+</I>><i>
+</I>><i>Andrew Church schrieb:
+</I>>><i> Passwords are no longer stored as simple strings, since each password
+</I>>><i> can be encrypted with a different method (cipher). To save data from
+</I>>><i> a Password structure, you need to save both the contents of
+</I>>><i> Password.password (as a binary buffer, not a string) and the string
+</I>>><i> pointed to by Password.cipher (which may be NULL). To restore a
+</I>>><i> Password structure, fill in the password and cipher fields in a
+</I>>><i> temporary variable, then use copy_password() to copy the data to the
+</I>>><i> destination Password structure.
+</I>>><i>
+</I>>><i> --Andrew Church
+</I>>><i> <A HREF="http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding">achurch at achurch.org</A>
+</I>>><i> <A HREF="http://achurch.org/">http://achurch.org/</A>
+</I>>><i>
+</I>>><i>
+</I>>>><i> Hy,
+</I>>>><i>
+</I>>>><i> I'm migrating my old modules for ircservices-5.1.11, but I've seen that
+</I>>>><i> there were many changes in the nickgroupinfo_ struct.
+</I>>>><i> "char pass[PASSMAX];" were replaced by "Password pass;", so my module
+</I>>>><i> won't compile anymore:
+</I>>>><i>
+</I>>>><i> modules/nickserv/dbsynch.c: In function `copy_data':
+</I>>>><i> modules/nickserv/dbsynch.c:83: error: incompatible type for argument 1
+</I>>>><i> of `__builtin_strncpy'
+</I>>>><i>
+</I>>>><i>
+</I>>>><i> Line of this code:
+</I>>>><i>
+</I>>>><i> static void copy_data(MYSQL_ROW row, unsigned long *lengths, NickInfo
+</I>>>><i> *ni, NickGroupInfo *ngi) {
+</I>>>><i> char temp[100];
+</I>>>><i> strncpy(ngi->pass, row[field(MYSQL_FIELD_USERINFO_PASSWORD)], PASSMAX <
+</I>>>><i> lengths[field(MYSQL_FIELD_USERINFO_PASSWORD)] ? PASSMAX :
+</I>>>><i> lengths[field(MYSQL_FIELD_USERINFO_PASSWORD)] + 1);
+</I>>>><i> ....
+</I>>>><i>
+</I>>>><i> When I replace "ngi->pass" by "&ngi->pass" there's only a warning left,
+</I>>>><i> but by running this function copy_data my services crashes.
+</I>>>><i>
+</I>>>><i> Any Ideas?
+</I>>>><i> Regards.
+</I>>>><i> ------------------------------------------------------------------
+</I>>>><i> To unsubscribe or change your subscription options, visit:
+</I>>>><i> <A HREF="http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding">http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding</A>
+</I>>>><i>
+</I>>>><i> ------------------------------------------------------------------------
+</I>>>><i>
+</I>>>><i> ------------------------------------------------------------------
+</I>>>><i> To unsubscribe or change your subscription options, visit:
+</I>>>><i> <A HREF="http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding">http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding</A>
+</I>><i>
+</I></PRE>
+
+
+<!--endarticle-->
+ <HR>
+ <P><UL>
+ <!--threads-->
+ <LI>Previous message: <A HREF="003323.html">[IRCServices Coding] Migrating Modules to 5.1...
+</A></li>
+ <LI>Next message: <A HREF="003325.html">[IRCServices Coding] [IRCServices] akick not setting channel ban
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#3324">[ date ]</a>
+ <a href="thread.html#3324">[ thread ]</a>
+ <a href="subject.html#3324">[ subject ]</a>
+ <a href="author.html#3324">[ author ]</a>
+ </LI>
+ </UL>
+
+</body></html>